single threaded web servers

single threaded web servers

guy keren guy.choo.keren at gmail.com
Sat Jul 2 20:41:54 IDT 2016


you didn't say you needed dynamic content - your example "code" seemed 
to focus on serving static content.

try to be more specific about what you need

--guy

On 07/02/2016 06:41 PM, Erez D wrote:
>
>
> On Sat, Jul 2, 2016 at 2:00 PM, guy keren <guy.choo.keren at gmail.com
> <mailto:guy.choo.keren at gmail.com>> wrote:
>
>
>     https://en.wikipedia.org/wiki/Thttpd
>
> dont know if it fits my requierments but last version dated 2014
>
>
>
>     and
>
>     https://www.lighttpd.net/
>
> uses fastcgi. fastcgi is multithreaded.
>
>
>
>     both existed before anyone used javascript on server side, as far as
>     i know
>
>     (and they are written in C, not C++)
>
>     --guy
>
>
>     On 07/02/2016 10:49 AM, Erez D wrote:
>
>         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.shapira at gmail.com <mailto:amos.shapira at gmail.com>
>         <mailto:amos.shapira at gmail.com <mailto:amos.shapira at 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 <erez0001 at gmail.com
>         <mailto:erez0001 at gmail.com>
>              <mailto:erez0001 at gmail.com <mailto:erez0001 at 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 at cs.huji.ac.il <mailto:Linux-il at cs.huji.ac.il>
>         <mailto:Linux-il at cs.huji.ac.il <mailto:Linux-il at 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 at cs.huji.ac.il <mailto:Linux-il at cs.huji.ac.il>
>         http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
>
>
>
>     _______________________________________________
>     Linux-il mailing list
>     Linux-il at cs.huji.ac.il <mailto:Linux-il at cs.huji.ac.il>
>     http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
>
>




More information about the Linux-il mailing list