Re: [Simpleweb-Support] Non Executor-based Asynchronous Service
Brought to you by:
niallg
From: Niall G. <gal...@ya...> - 2014-06-12 02:06:47
|
Hi, The whole point of this project is to offer a HTTP server that can handle hundreds of thousands of concurrent connections without the need for thread per connection. I have tested several billion requests at a concurrency of 200,000. Spend some time looking at how it works, do not think of servlets, there is little to no relationship. I have also implemented WebSockets for Simple, ill release it within a few months when I get some time. Niall -------------------------------------------- On Wed, 11/6/14, Kai Schutte <sch...@gm...> wrote: Subject: Re: [Simpleweb-Support] Non Executor-based Asynchronous Service To: "Simple support and user issues" <sim...@li...> Received: Wednesday, 11 June, 2014, 10:38 AM Now take this with a grain of salt cause I'm using an older version from 3 years ago, but, as far as I know: Simple doesn't use one thread for every one request at all, quite the opposite: it is essentially is a select based IO http server. The async tasks of Simple are just objects that give you acess to each request / underlining connection. Simple doesn't manage nor create threads itself, not at it's core at least. This is one of the main reasons I use it, cause I made my own Thread manager. The documentation you linked is just a very simple example of how to handle a request asynchronously. If you don't want your thread count to explode, you need to build your own thread manager, that will poll the org.simpleframework.http.Request objects for those that are ready to become active, something like this: https://commons.apache.org/dormant/threadpool/ As for handling several HTTP requests from a single connection in Simple, I know it's possible, but honestly I forgot and I can't find it right now. Btw, if you're designing a new project, HTTP may not be the best choice for long connections (ie, several days), not even cause of Simple, but cause most long range routers are trained to drop HTTP connections after a while, and besides, HTTP really isn't meant for persistant connections. So I'd suggest you look into WebSocket protocol... it's not very popular, but it is standardised, kind of a bastard child of HTTP, works with most browsers, and there's decent implementation in nearly every language, and is specifically designed for processing many, even concurrent server requests over a single, long term / persistent connection. So if you're just looking to shove some XML or JSON back and forth, then please have a look at WebSocket :) Bon Courage :) -k On Wed, Jun 11, 2014 at 1:00 PM, Luis Antunes <lan...@gm...> wrote: Hi, I have read through the section on Asynchronous Services located at http://www.simpleframework.org/doc/tutorial/tutorial.php. I notice that the example uses a java.util.concurrent.Executor to spawn the asynchronous task. Is it possible to do the same without using a thread-based approach? That is, can we achieve the same result using a Selector and NIO? For example, I thought about using the SocketChannel associated with the Request to register with a Selector, but I cannot see any way to access that SocketChannel. I am trying to allow potentially many requests to remain suspended for long periods of time. If I start a new thread for every request, this becomes resource-intensive and expensive. Using NIO, I could have just a single separate thread that monitors the Selector. Any help you could provide would be much appreciated. By the way, thanks for contributing such great software! Luis ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems _______________________________________________ Simpleweb-Support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simpleweb-support -----Inline Attachment Follows----- ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems -----Inline Attachment Follows----- _______________________________________________ Simpleweb-Support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simpleweb-support |