Re: [Simpleweb-Support] Long live connections number.
Brought to you by:
niallg
From: Niall G. <gal...@ya...> - 2007-11-01 20:44:42
|
Hi, Ya, you can do this if you like, its pretty easy. The request is not completed until you close the conneciton. So you can do the following: public class MyService extends Service{ private MyMessenger messenger; public MyService(Context context) { super(context); messenger = new MyMessenger(); messenger.start(); } public void process(Request req, Response resp){ MyTrasaction t = new MyTrasaction(req, resp); messenger.process(t); } } public class MyMessenger extends Thread { private LinkedBlockingQueue<Transaction> queue; public MyMessenger() { queue = new LinkedBlockingQueue<MyTransaction>(); } public void process(MyTransaction t) { q.offer(t); } public void run() { while(true) { MyTransaciton t = queue.take(); someProcess(t); } } public void someProcess(MyTransaciton t) { // do what you want here } } public class MyTransaction { private Response resp; private Request req; public MyTransaction(Request req, Response resp) { this.req = req; this.resp = resp; } public Request getRequest(){ return req; } public Response getResponse() { return resp; } public void close() { resp.getOutputStream().close(); } } So the connection is not closed and completed until you close your transaction. You can do what you want from there. Whether its events or backend processing, the connection will stay alive until you decide. The container NEVER closes the connection, when its closed is up to you. Niall --- Andrew Ryzhokhin <ryz...@gm...> wrote: > Hi, > > Unfortunately I planed to have more concurrent > long-lived requests than 100 > and than 1000 and more. :( > My application is similarly of instant messenger. > And each user use one > long-lived request to the server. > > May be the Simple have a mode when it haven`t any > restriction of request > processing? > > What happen with server if I increase the number of > threads to one million? > > On 11/1/07, Niall Gallagher > <gal...@ya...> wrote: > > > > Hi, > > > > In this case you need to increase the number of > > threads in the thread pool. You need to do the > > following. > > > > ProcessQueue.getInstance().resize(100) > > > > This will increase the number of concurrent > requests > > to 100. > > > > Niall > > > > --- Andrew Ryzhokhin <ryz...@gm...> wrote: > > > > > Hi Niall, > > > > > > > > > Thank you for the answer. Yes, you are right if > it > > > relates to quick > > > processing HTTP requests. > > > The key point of my question is 'long-lived > > > HTTP connections'. You can use the following > code > > > to reproduce my problem: > > > > > > Implement test handler with long time > processing, > > > for example 10 secs. > > > > > > public class DelayHandler extends Service { > > > > > > public DelayHandler(Context context) > > > { > > > super(context); > > > } > > > > > > > > > protected void process(Request request, Response > > > response) throws Exception > > > { > > > > > > String param = > > > request.getParameter("counter"); > > > Log.debug(this, "Start for: " + param); > > > Thread.sleep(10000); > > > response.commit(); > > > Log.debug(this, "End for: " + param); > > > } > > > } > > > > > > I used JMeter for load testing. My test sends 40 > > > HTTP Requests to > > > resource processed with DelayHandler service in > the > > > same time. > > > > > > All my requests have parameter 'counter' with > number > > > of request. But > > > handler is processed only first 20 requests and > then > > > other 20 > > > requests. > > > > > > Seems this restriction is hardcoded in the > > > ProcessQueue.java at line 64. > > > > > > The log I received is attached below, please, to > > > draw attention to time > > > (seconds) and numbers of requests: > > > > ================================================== > > > > > > > -- > Regards > Andrew Ryzhokhin > www.ardas.dp.ua > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? > Stop. > Now Search log events and configuration files using > AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/> _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |