Erlang Mailing Lists

Author Message

<  Yaws mailing list  ~  Proposal: throttle incoming requests

tobbe
Posted: Wed Nov 01, 2006 12:50 pm Reply with quote
User Joined: 19 Jan 2005 Posts: 274 Location: Stockholm, Sweden
If Yaws deliver requests faster than what the rest
of the system can handle them, it would be nice
to be able to throttle the amount of incoming requests.

I was thinking of adding a global parameter:

REQUESTS_PER_SECOND=<integer between 1 and 1000>

The yaws_server.erl could be modified like this:
--------------------------------------------------
do_accept(GS) when GS#gs.ssl == nossl ->
?Debug("wait in accept ... ~n",[]),
+ sleep(GS#gs.req_per_sec),
gen_tcp:accept(GS#gs.l);
do_accept(GS) when GS#gs.ssl == ssl ->
+ sleep(GS#gs.req_per_sec),
ssl:accept(GS#gs.l,10000).

+%% Other values make no sense
+sleep(I) when I>1,I=<1000 ->
+ Timeout = trunc(1000/I),
+ receive after Timeout -> true end;
+sleep(_) ->
+ true.
-------------------------------------------------

So what do you think about this?

Cheers, Tobbe


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist
View user's profile Send private message Send e-mail Visit poster's website
noss
Posted: Wed Nov 01, 2006 1:04 pm Reply with quote
User Joined: 09 Oct 2005 Posts: 290
On 11/1/06, Torbjorn Tornkvist <tobbe@tornkvist.org> wrote:
> If Yaws deliver requests faster than what the rest
> of the system can handle them, it would be nice
> to be able to throttle the amount of incoming requests.
>
> I was thinking of adding a global parameter:

How about an interface to change this value while running? So one could
regulate it based on application-specific load measurements.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist
View user's profile Send private message
Guest
Posted: Wed Nov 01, 2006 1:04 pm Reply with quote
Guest
Torbjorn Tornkvist <tobbe@tornkvist.org> wrote:
> If Yaws deliver requests faster than what the rest
> of the system can handle them, it would be nice
> to be able to throttle the amount of incoming requests.
>
> I was thinking of adding a global parameter:
>
> REQUESTS_PER_SECOND=<integer between 1 and 1000>
>
> The yaws_server.erl could be modified like this:
> --------------------------------------------------
> do_accept(GS) when GS#gs.ssl == nossl ->
> ?Debug("wait in accept ... ~n",[]),
> + sleep(GS#gs.req_per_sec),
> gen_tcp:accept(GS#gs.l);
> do_accept(GS) when GS#gs.ssl == ssl ->
> + sleep(GS#gs.req_per_sec),
> ssl:accept(GS#gs.l,10000).
>
> +%% Other values make no sense
> +sleep(I) when I>1,I=<1000 ->
> + Timeout = trunc(1000/I),
> + receive after Timeout -> true end;
> +sleep(_) ->
> + true.
> -------------------------------------------------
>
> So what do you think about this?

Without looking at how the Yaws request receiving code looks like, it
appears to me that REQUESTS_PER_SECOND is rather SLEEPTIME_PER_REQUEST?

Besides that, couldn't such a rate limiting be made more dynamic if it
was based on the run queue length as reported by erlang:statistics/1?
Ulf Wiger indicated to me that that could be a good source of indication
that you are overloaded, and should start backing off. I've been
planning on implementing it in YXA but haven't found the time yet so I
cannot tell you if it works in practice.

/Fredrik


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist
tobbe
Posted: Wed Nov 01, 2006 1:23 pm Reply with quote
User Joined: 19 Jan 2005 Posts: 274 Location: Stockholm, Sweden
Christian S wrote:
> On 11/1/06, Torbjorn Tornkvist <tobbe@tornkvist.org> wrote:
>> If Yaws deliver requests faster than what the rest
>> of the system can handle them, it would be nice
>> to be able to throttle the amount of incoming requests.
>>
>> I was thinking of adding a global parameter:
>
> How about an interface to change this value while running? So one could
> regulate it based on application-specific load measurements.

Yes, it could be a good idea.

--Tobbe


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist
View user's profile Send private message Send e-mail Visit poster's website
tobbe
Posted: Wed Nov 01, 2006 1:28 pm Reply with quote
User Joined: 19 Jan 2005 Posts: 274 Location: Stockholm, Sweden
Fredrik Thulin wrote:
>
> Without looking at how the Yaws request receiving code looks like, it
> appears to me that REQUESTS_PER_SECOND is rather SLEEPTIME_PER_REQUEST?

Hm..yes..or perhaps MAX_REQUESTS_PER_SECOND.

>
> Besides that, couldn't such a rate limiting be made more dynamic if it
> was based on the run queue length as reported by erlang:statistics/1?

But if you have a large system, involving heavy use of mnesia etc, it
is hard to measure this. This is an easy way (perhaps too easy?) to
protect the rest of the system from being overloaded.

--Tobbe

> Ulf Wiger indicated to me that that could be a good source of indication
> that you are overloaded, and should start backing off. I've been
> planning on implementing it in YXA but haven't found the time yet so I
> cannot tell you if it works in practice.
>
> /Fredrik
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist
View user's profile Send private message Send e-mail Visit poster's website
noss
Posted: Wed Nov 01, 2006 1:41 pm Reply with quote
User Joined: 09 Oct 2005 Posts: 290
On 11/1/06, Torbjorn Tornkvist <tobbe@tornkvist.org> wrote:
> Christian S wrote:
> > How about an interface to change this value while running? So one could
> > regulate it based on application-specific load measurements.
>
> Yes, it could be a good idea.

More thinking about the issue.

To make a working automatic controller one also needs
information about current request frequency.

Otherwise it is hard to know how sleep time should be modified
to modify throttling in the desired direction.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum