babelouest / ulfius

Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
https://babelouest.github.io/ulfius
GNU Lesser General Public License v2.1
1.08k stars 182 forks source link

Performance about ulfius #219

Closed wuliyueyue closed 2 years ago

wuliyueyue commented 2 years ago

Hello, when I use ulfius_start_framework() function in the server. The client uses three threads to send requests all the time, the performance is 3000tps. And when I using ulfius_start_framework_with_mhd_options(&instance, MHD_USE_POLL_INTERNALLY, mhd_ops); , it does not improve the performance. here is the code

    struct MHD_OptionItem mhd_ops[4];
    mhd_ops[0].option = MHD_OPTION_NOTIFY_COMPLETED;
    mhd_ops[0].value = (intptr_t)mhd_request_completed;
    mhd_ops[0].ptr_value = NULL;

    mhd_ops[1].option = MHD_OPTION_URI_LOG_CALLBACK;
    mhd_ops[1].value = (intptr_t)ulfius_uri_logger;
    mhd_ops[1].ptr_value = NULL;

    mhd_ops[2].option = MHD_OPTION_THREAD_POOL_SIZE;
    mhd_ops[2].value = 3;
    mhd_ops[2].ptr_value = NULL;

    mhd_ops[3].option = MHD_OPTION_END;
    mhd_ops[3].value = 0;
    mhd_ops[3].ptr_value = NULL;
    res = ulfius_start_framework_with_mhd_options(&instance, MHD_USE_POLL_INTERNALLY, mhd_ops);
babelouest commented 2 years ago

Hello @wuliyueyue ,

Can you elaborate on what you would like to achieve regarding performance? It may be possible that the default mhd options in Ulfius are the one which gives you best performance in your architecture.

wuliyueyue commented 2 years ago

I want it achieve 15000tps. When I use the examples to test the performance with MHD_USE_POLL_INTRENALLY mhg_flag and default mhd options in Ulfius, it reached16000tps. It may be that in the callback function, my code processing time is too long, resulting in too small TPS. Thanks a lot!

babelouest commented 2 years ago

Good too know about your benchmark! Can this issue can be closed then?

wuliyueyue commented 2 years ago

Of course, thanks for your help!

babelouest commented 2 years ago

Good, you can still open a discussion or an issue if you need more help!