[libmicrohttpd] Question on Async support

2018-08-23 Thread Santos Das
Hi,

Can anyone please confirm if libmicrohttpd supports the Async handling?

Also, any information on the performance of libmicrohttps will be useful.

thanks, santos


Re: [libmicrohttpd] Question on Async support

2018-08-23 Thread Christian Grothoff
On 08/23/2018 06:21 PM, Santos Das wrote:
> Hi,
> 
> Can anyone please confirm if libmicrohttpd supports the Async handling?

Yes, it supports asynchronous processing.

> Also, any information on the performance of libmicrohttps will be useful.

Let's just say if used properly, it will never be anywhere near the
bottleneck. We know people running 100,000 requests/s on a single system
with MHD years ago. Quite likely to do more today, but very difficult to
test: when benchmarking, you will always be benchmarking your clients,
your network or your application logic long before hitting any MHD
threshold (on sane operating systems).



signature.asc
Description: OpenPGP digital signature


Re: [libmicrohttpd] Question on Async support

2018-08-23 Thread Santos Das
Hi,

Thank you for the quick reply. I have one more question, please help in
clarifying -

Can "libmicrohttpd" run as a part of the application event loop or is
it *mandatory
*for the  "libmicrohttpd"  to have its own event loop?

thanks, santos

On Thu, Aug 23, 2018 at 11:58 PM, Christian Grothoff 
wrote:

> On 08/23/2018 06:21 PM, Santos Das wrote:
> > Hi,
> >
> > Can anyone please confirm if libmicrohttpd supports the Async handling?
>
> Yes, it supports asynchronous processing.
>
> > Also, any information on the performance of libmicrohttps will be useful.
>
> Let's just say if used properly, it will never be anywhere near the
> bottleneck. We know people running 100,000 requests/s on a single system
> with MHD years ago. Quite likely to do more today, but very difficult to
> test: when benchmarking, you will always be benchmarking your clients,
> your network or your application logic long before hitting any MHD
> threshold (on sane operating systems).
>
>


Re: [libmicrohttpd] Question on Async support

2018-08-23 Thread silvioprog
Hello Santos.

Yes, you can use your own main loop. Please see:

"*The fourth threading model (used when no specific flag is given), uses no
threads. Instead, the main application must (periodically) request file
descriptor sets from MHD, perform a select call and then call MHD_run.
MHD_run will then process HTTP requests as usual and return. MHD_run is
guaranteed to not block; however, access handlers and response processing
callbacks that it invokes may block. This mode is useful if a
single-threaded implementation is desired and in particular if the main
application already uses a select loop for its processing.*" More ...


Enjoy MHD! ☺

On Thu, Aug 23, 2018 at 3:36 PM Santos Das  wrote:

> Hi,
>
> Thank you for the quick reply. I have one more question, please help in
> clarifying -
>
> Can "libmicrohttpd" run as a part of the application event loop or is it 
> *mandatory
> *for the  "libmicrohttpd"  to have its own event loop?
>
> thanks, santos
>
> On Thu, Aug 23, 2018 at 11:58 PM, Christian Grothoff 
> wrote:
>
>> On 08/23/2018 06:21 PM, Santos Das wrote:
>> > Hi,
>> >
>> > Can anyone please confirm if libmicrohttpd supports the Async handling?
>>
>> Yes, it supports asynchronous processing.
>>
>> > Also, any information on the performance of libmicrohttps will be
>> useful.
>>
>> Let's just say if used properly, it will never be anywhere near the
>> bottleneck. We know people running 100,000 requests/s on a single system
>> with MHD years ago. Quite likely to do more today, but very difficult to
>> test: when benchmarking, you will always be benchmarking your clients,
>> your network or your application logic long before hitting any MHD
>> threshold (on sane operating systems).
>>
>>
>

-- 
Silvio Clécio


Re: [libmicrohttpd] Question on Async support

2018-08-23 Thread Christian Grothoff
On 08/23/2018 08:36 PM, Santos Das wrote:
> Hi,
> 
> Thank you for the quick reply. I have one more question, please help in
> clarifying -
> 
> Can "libmicrohttpd" run as a part of the application event loop or is it
> *_mandatory _*for the  "libmicrohttpd"  to have its own event loop?

It can run as part of the application's event loop.

You can find a simple example here:

https://git.taler.net/exchange.git/tree/src/bank-lib/fakebank.c

The application's event loop here is easily identified as it is the
GNUNET_SCHEDULER*-API.

The code shows integration both with the select() and epoll()-based
versions of MHD.



signature.asc
Description: OpenPGP digital signature


Re: [libmicrohttpd] Question on Async support

2018-08-23 Thread Santos Das
Hi,

Thanks a lot. Is there any significant performance impact when it runs in
this mode ?

Has anyone compared its performance against "mongoose " ?

I''m evaluating a http library for my C++ based application microservices
.  I am evaluating libraries that can provide our C++ workers with native
HTTP capabilities.


I’m defining native as:

   - No additional threads other than those spawned by the application when
   it chooses to use blocking calls (entirely optional)
   - No additional queueing
   - Native sockets interface with full use of listen, accept, bind,
   connect, recv, send.


Do you think libmicrohttpd is the best choice or is there any better
alternatives for me ?

Please advise.

thanks, santos

On Fri, Aug 24, 2018 at 12:15 AM, silvioprog  wrote:

> Hello Santos.
>
> Yes, you can use your own main loop. Please see:
>
> "*The fourth threading model (used when no specific flag is given), uses
> no threads. Instead, the main application must (periodically) request file
> descriptor sets from MHD, perform a select call and then call MHD_run.
> MHD_run will then process HTTP requests as usual and return. MHD_run is
> guaranteed to not block; however, access handlers and response processing
> callbacks that it invokes may block. This mode is useful if a
> single-threaded implementation is desired and in particular if the main
> application already uses a select loop for its processing.*" More ...
> 
>
> Enjoy MHD! ☺
>
> On Thu, Aug 23, 2018 at 3:36 PM Santos Das  wrote:
>
>> Hi,
>>
>> Thank you for the quick reply. I have one more question, please help in
>> clarifying -
>>
>> Can "libmicrohttpd" run as a part of the application event loop or is it 
>> *mandatory
>> *for the  "libmicrohttpd"  to have its own event loop?
>>
>> thanks, santos
>>
>> On Thu, Aug 23, 2018 at 11:58 PM, Christian Grothoff > > wrote:
>>
>>> On 08/23/2018 06:21 PM, Santos Das wrote:
>>> > Hi,
>>> >
>>> > Can anyone please confirm if libmicrohttpd supports the Async handling?
>>>
>>> Yes, it supports asynchronous processing.
>>>
>>> > Also, any information on the performance of libmicrohttps will be
>>> useful.
>>>
>>> Let's just say if used properly, it will never be anywhere near the
>>> bottleneck. We know people running 100,000 requests/s on a single system
>>> with MHD years ago. Quite likely to do more today, but very difficult to
>>> test: when benchmarking, you will always be benchmarking your clients,
>>> your network or your application logic long before hitting any MHD
>>> threshold (on sane operating systems).
>>>
>>>
>>
>
> --
> Silvio Clécio
>


Re: [libmicrohttpd] Question on Async support

2018-08-23 Thread silvioprog
You're welcome. ☺

On Thu, Aug 23, 2018 at 4:09 PM Santos Das  wrote:

> Hi,
>
> Thanks a lot. Is there any significant performance impact when it runs in
> this mode ?
>

I'm using the built-in MHD main loop through a recent released project
called Sagui Project . Take a look
at some benchmarks vs NodeJS/Nginx
 (this
high-performance would not be possible without MHD library, thanks
Christian, Evgeny and all). You should test MHD in a minimal project to
check its features. Feel free to ask questions regarding it.

Has anyone compared its performance against "mongoose " ?
>

Some time ago: I tested MHD vs Mongoose vs Soup
.
I'm inclined to add Mongoose in my new tests
.


> I''m evaluating a http library for my C++ based application microservices
> .  I am evaluating libraries that can provide our C++ workers with native
> HTTP capabilities.
>
>
> I’m defining native as:
>
>- No additional threads other than those spawned by the application
>when it chooses to use blocking calls (entirely optional)
>- No additional queueing
>- Native sockets interface with full use of listen, accept, bind,
>connect, recv, send.
>
>
Please take a look at MHD reference manual
 and this
tutorial , it
contains a lot of info and tips regarding the library features. Also, take
a look at daemon.c and connection.c files here
. ☺


> Do you think libmicrohttpd is the best choice or is there any better
> alternatives for me ?
>

I'm working a lot to release a new project for Delphi XE (Pascal and C++)
and Free Pascal
, and I have
plan to support Python and Java too. I tested a lot of libraries before
(libsoup, mongoose, libuv based libraries, libevent based libraries and so
on), but MHD was the minimal, simplest, safe and performatic ANSI C
library to develop cross-platform HTTP(S) servers. So, since we are in a
similar scenario, it seems MHD is the best choice for you, please take a
time to test it. 😉


> Please advise.
>
> thanks, santos
>

--
Silvio Clécio


Re: [libmicrohttpd] Question on Async support

2018-08-23 Thread Christian Grothoff
On 08/23/2018 09:09 PM, Santos Das wrote:
> Hi,
> 
> Thanks a lot. Is there any significant performance impact when it runs
> in this mode ?

Not inherently, but you don't get the thread-pool feature that way (at
least not without quite a bit of work by you!).  My real
high-performance setups use the thread pool (because my application
logic requires some CPU time, not so much for MHD), but of course you
could hack up your own.  But just FYI: that's not trivial.

> Has anyone compared its performance against "mongoose " ?

I'm not aware of a direct 1:1 comparison, but as I said, it is very hard
to benchmark the HTTP logic itself.

> I''m evaluating a http library for my C++ based application
> microservices .  I am evaluating libraries that can provide our C++
> workers with native HTTP capabilities. 
> 
> 
> I’m defining native as:
> 
>   * No additional threads other than those spawned by the application
> when it chooses to use blocking calls (entirely optional)
>   * No additional queueing
>   * Native sockets interface with full use of listen, accept, bind,
> connect, recv, send.
> 
> 
> Do you think libmicrohttpd is the best choice or is there any better
> alternatives for me ?

Well, we have a list of alternatives on the MHD web site. But naturally
few people on this list would think they are as useful for _their_
usecases. ;-)

Note that there is some C++ wrapper around MHD here:
 https://github.com/etr/libhttpserver

But I don't know if it is any good (never tried).

Happy hacking!

Christian



Re: [libmicrohttpd] Question on Async support

2018-08-23 Thread silvioprog
Hello Christian,

On Thu, Aug 23, 2018 at 8:58 PM Christian Grothoff 
wrote:
[...]

> Well, we have a list of alternatives on the MHD web site. But naturally
> few people on this list would think they are as useful for _their_
> usecases. ;-)


I would like to add my library to the page "Projects that use
libmicrohttpd". How to do that? :-)

Thank you!

-- 
Silvio Clécio