diff options
Diffstat (limited to 'archives/extend/2013-April/000125.html')
-rw-r--r-- | archives/extend/2013-April/000125.html | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/archives/extend/2013-April/000125.html b/archives/extend/2013-April/000125.html new file mode 100644 index 00000000..6fd69519 --- /dev/null +++ b/archives/extend/2013-April/000125.html @@ -0,0 +1,140 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<HTML> + <HEAD> + <TITLE> [99s-extend] cowboy how to ruduce the memory usage per long-hold connection + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20cowboy%20how%20to%20ruduce%20the%20memory%20usage%20per%0A%09long-hold%20connection&In-Reply-To=%3CCAJ0zLRPcYmH1OXeiw2aZHLtoqqdW%3Ddu0rhonF53xdCbMUmnCLw%40mail.gmail.com%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <style type="text/css"> + pre { + white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */ + } + </style> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="000124.html"> + <LINK REL="Next" HREF="000126.html"> + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[99s-extend] cowboy how to ruduce the memory usage per long-hold connection</H1> + <B>rambocoder</B> + <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20cowboy%20how%20to%20ruduce%20the%20memory%20usage%20per%0A%09long-hold%20connection&In-Reply-To=%3CCAJ0zLRPcYmH1OXeiw2aZHLtoqqdW%3Ddu0rhonF53xdCbMUmnCLw%40mail.gmail.com%3E" + TITLE="[99s-extend] cowboy how to ruduce the memory usage per long-hold connection">erlang at rambocoder.com + </A><BR> + <I>Fri Apr 26 15:11:53 CEST 2013</I> + <P><UL> + <LI>Previous message: <A HREF="000124.html">[99s-extend] cowboy how to ruduce the memory usage per long-hold connection +</A></li> + <LI>Next message: <A HREF="000126.html">[99s-extend] [ANN] Cowboy 0.8.4 +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#125">[ date ]</a> + <a href="thread.html#125">[ thread ]</a> + <a href="subject.html#125">[ subject ]</a> + <a href="author.html#125">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>Is 13.6K/connection considered a lot? Once you start doing SSL, each +connection will be about 80K, IMHO the most important factor for huge +ammount of COMET users is latency, which Cowboy and Erlang do great. + +-rambocoder + +On Fri, Apr 26, 2013 at 2:11 AM, yongboy <<A HREF="https://lists.ninenines.eu/listinfo/extend">yongboy at gmail.com</A>> wrote: + +><i> I have tested one long-hold webapp, when 512000 user connected, the app +</I>><i> used +</I>><i> 6801M memory, 6801M*1024K / 512000 = 13.6K/Connection. +</I>><i> +</I>><i> Does anyone give me some advice on how to reduce the memory usage per one +</I>><i> connection, thanks very much ! +</I>><i> +</I>><i> Here is the code snippet: +</I>><i> +</I>><i> start(_Type, _Args) -> +</I>><i> Dispatch = cowboy_router:compile([ +</I>><i> {'_', [{'_', htmlfile_handler, []}]} +</I>><i> ]), +</I>><i> cowboy:start_http(my_http_listener, 100, +</I>><i> [{port, 8000}, {max_connections, infinity}], +</I>><i> [{env, [{dispatch, Dispatch}]}] +</I>><i> ), +</I>><i> count_server:start(), +</I>><i> htmlfilesimple_sup:start_link(). +</I>><i> +</I>><i> ...... +</I>><i> +</I>><i> -module(htmlfile_handler). +</I>><i> -behaviour(cowboy_loop_handler). +</I>><i> -export([init/3, info/3, terminate/3]). +</I>><i> -define(HEARBEAT_TIMEOUT, 20*1000). +</I>><i> -record(status, {count=0}). +</I>><i> +</I>><i> init(_Any, Req, State) -> +</I>><i> NowCount = count_server:welcome(), +</I>><i> io:format("online user ~p :))~n", [NowCount]), +</I>><i> +</I>><i> output_first(Req), +</I>><i> Req2 = cowboy_req:compact(Req), +</I>><i> {loop, Req2, State, hibernate}. +</I>><i> +</I>><i> %% POST/Short Request +</I>><i> info(_Any, Req, State) -> +</I>><i> {loop, Req, State, hibernate}. +</I>><i> +</I>><i> output_first(Req) -> +</I>><i> {ok, Reply} = cowboy_req:chunked_reply(200, [{<<"Content-Type">>, +</I>><i> <<"text/html; charset=utf-8">>}, +</I>><i> +</I>><i> {<<"Connection">>, <<"keep-alive">>}], Req), +</I>><i> cowboy_req:chunk(<<"<html><body><script>var _ = function (msg) { +</I>><i> parent.s._(msg, document); +</I>><i> };</script> +</I>><i> ">>, +</I>><i> Reply), +</I>><i> cowboy_req:chunk(gen_output("1::"), Reply). +</I>><i> +</I>><i> gen_output(String) -> +</I>><i> DescList = io_lib:format("<script>_('~s');</script>", [String]), +</I>><i> list_to_binary(DescList). +</I>><i> +</I>><i> terminate(Reason, _Req, _State) -> +</I>><i> NowCount = count_server:bye(), +</I>><i> io:format("offline user ~p :(( ~n", [NowCount]). +</I>><i> +</I>><i> +</I>><i> +</I>><i> +</I>><i> _______________________________________________ +</I>><i> Extend mailing list +</I>><i> <A HREF="https://lists.ninenines.eu/listinfo/extend">Extend at lists.ninenines.eu</A> +</I>><i> <A HREF="http://lists.ninenines.eu:81/listinfo/extend">http://lists.ninenines.eu:81/listinfo/extend</A> +</I>><i> +</I>><i> +</I>-------------- next part -------------- +An HTML attachment was scrubbed... +URL: <<A HREF="http://lists.ninenines.eu/archives/extend/attachments/20130426/b1e8ae7a/attachment.html">http://lists.ninenines.eu/archives/extend/attachments/20130426/b1e8ae7a/attachment.html</A>> +</PRE> + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="000124.html">[99s-extend] cowboy how to ruduce the memory usage per long-hold connection +</A></li> + <LI>Next message: <A HREF="000126.html">[99s-extend] [ANN] Cowboy 0.8.4 +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#125">[ date ]</a> + <a href="thread.html#125">[ thread ]</a> + <a href="subject.html#125">[ subject ]</a> + <a href="author.html#125">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend +mailing list</a><br> +</body></html> |