ohler55 / agoo-c

Agoo webserver in C.
MIT License
146 stars 16 forks source link

Clustering possible? #10

Closed dalisoft closed 4 years ago

dalisoft commented 4 years ago

Hi @ohler55

I tried without SSL of #9 and able to start.

First thing, i can use same port on all OS, not only Linux (called ./simple and all of them are successfully started), but performance wasn't improvement as it's not used my all cores (maybe i'd think wrong).

Clustering possible (with listening to same port)?

Thanks

(sorry for bad english)

dalisoft commented 4 years ago

Or maybe this line defines thread / cluster count?

If yes, why changing it to 4 (my all core threads) does not improve performance?

ohler55 commented 4 years ago

There are several factors to consider when trying to make use of multiple threads. First that are the IO threads that read the HTTP requests and send the responses. More threads there help to some extent if you have lots of connections but there is a limit with the bandwidth of the port on the machine. Second, there is the processing of the request. That is what the thread_cnt is for. If heavy processing is required then more threads help. If the processing is very simple then there is no need for additional processing threads as that will not speed up processing. Adding more might even slow down processing as more threads have to be serviced.

For Agoo-C there is no advantage to splitting the app into multiple separate processes like Agoo (Ruby) does. Agoo does that to compensate for the Ruby global lock which C does not have.

I'm not sure how you are measuring performance but You can also consider changing the value of these.

agoo_io_loop_ratio = 1.0;
agoo_poll_wait = 0.1;

What kind of performance, (latency and rates) are you seeing? What machine and OS are you using?

dalisoft commented 4 years ago

Thanks for response.

I testing with wrk on macOS and performance nice even in one thread. But I expected performance gain when using more threads (how currently does express for example).

I will try change these values then let you know if there performance boost.

Thanks again

ohler55 commented 4 years ago

From issue #9 I see you are on a Mac. I develop and test on Mac as well as Linux. Linux give faster performance results.

dalisoft commented 4 years ago

I know, Linux is faster because it’s closer to hardware and less layer between program and cpu.

dalisoft commented 4 years ago
agoo_io_loop_ratio = 1.0;
agoo_poll_wait = 0.1;

This lines improved performance by really 10-15%. There available documents for how to get maximum possible performance?

ohler55 commented 4 years ago

You should try different values for each.

ohler55 commented 4 years ago

Something else you can try is using perfer to measure benchmarks. It handles high performance apps better than wrk.

dalisoft commented 4 years ago

Thanks for tool, i'll try 👍

dalisoft commented 4 years ago

As it’s supported at Core level we can close this issue