doing some research on servers i found out that i can handle more connections simultaneously as single threaded. on thread per connection i have a huge overhead, just think of the default 2MB stack per connection - 1000 connections is 2GB ram just for stack. however as single threaded, i can server connections by the 10,000s(or even a million).
later to my surprise, i found out that that was exactly one of the main considerations behind node.js but node.js requires code in js. and i am more of a c++ guy (and of course c++ is more efficient than js) C++ did a long way and now modern c++ (i.e. c++11 / c++14 ) is on par with other modern languages. the idea behind c++11/14 was to make it simple for beginners, while still keeping the option to control every bit for advanced users. one thing i hear people hate about c and c++ is its memory handling (malloc/free or new/delete), however in forgot about it years ago using shared_ptr ( now in c++11 and before that, use boost instead).. you can still control when it is freed if you want (in countrary to garbage-disposal-thread languages). as a matter of fact, i use this a lot - i create an object that cleans up,. and no matter how i exit the function it gets cleaned up. so i wanted a node.c++ instead of writing my own in theory simple single threaded web server usage code could look something like: int main() { auto server=HttpServer::create(80,[](Request &request) { if (request.header=="HelloWorld") { HttpResponse(200,"<H1>Hello, world</h1>"); } else { File::Read(request,header,[](bool success, string body) { if (success) HttpResponse(400,body); } else { HttpResponse(404); } ); } } ); } On Fri, Jul 1, 2016 at 4:58 AM, Amos Shapira <amos.shap...@gmail.com> wrote: > I'm curious - what's the background of this question? What's the original > goal that led you to ask this? > > On 28 June 2016 at 18:04, Erez D <erez0...@gmail.com> wrote: > >> i tried searching the web but got no result >> >> what web servers other than node.js are single threaded ? >> anyone has experience with one ? >> is there one in which the cgi is in c++ ? >> >> >> >> >> _______________________________________________ >> Linux-il mailing list >> Linux-il@cs.huji.ac.il >> http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il >> >> > > > -- > <http://au.linkedin.com/in/gliderflyer> >
_______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il