risoflora / brookframework

Microframework which helps to develop web Pascal applications.
https://risoflora.github.io/brookframework
GNU Lesser General Public License v2.1
233 stars 54 forks source link

HTTPServer under linux 64 Ubuntu #9

Closed glenswada closed 2 years ago

glenswada commented 5 years ago

Testing performance of provided HTTPServer example with weighttp in linux eventually results in "error: connect() failed: Cannot assign requested address (99)" Whereas same test against NGinx on same machine doesn't fail.

Running following test few times will see responses of HTTPServer eventually slow until errors occur. weighttp -n 10000 -t 5 -c 5 http://192.168.0.57:1080

Note I am running Mint Mate in VirtualBox on a Core i7-3770.

The results from HTTPServer example when working are 8000+ req/s. Not as fast as nginx 13000 req/s but impressive never-less. It seems Sagui library isn't releasing ports (lazy release) as fast as nginx so weighttp cannot connect to the server. Note that I have run much larger test against NGinx (-n 100000) and it still doesn't fail so don't think its an OS issue.

Thanks Glen

silvioprog commented 5 years ago

Hello @glenswada .

weighttp -n 10000 -t 5 -c 5 http://192.168.0.57:1080

I'm not familiar with weighttp, however, it seems the above line performs a c10k test.

For such situations, you should configure the server for high-demand. For example:

  BrookHTTPServer1.ThreadPoolSize := <Number of processors>;
  BrookHTTPServer1.ConnectionLimit := 10000; // for C10K situation

On Linux, you can get the <Number of processors> using:

$ getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1

Please try those configurations and let me know if it solves the problem.

glenswada commented 5 years ago

The number of processors returns 1. When I set threadpoolsize to 1 and connectionlimit to 10000 I get warning message "1 specified for thread pool size is ignored. Thread pool is not used."

I have run test again with connectionlimit = 10,000 and threadpoolsize to 0 and it still fails after couple of runs.

I also run test again with connectionlimit = 10,000 and threadpoolsize = 4 (no error message) and it still fails after couple of runs.

The speed decreases from 8000 req/s downto 2000 req/s after a couple runs before it starts to fail with warning from weighhttp "error: connect() failed: Cannot assign requested address (99)"

I am guessing the problem is that ports in Linux arn't being closed fast enough. https://developer.ibm.com/tutorials/l-sockpit/ mentions that with linux using the call setsockopt with SO_REUSEADDR option overcomes TCP socket TIME_WAIT state which can cause sockets to report error (EADDRINUSE) when they are not in use.

Thanks Glen


From: silvioprog [mailto:notifications@github.com] Sent: Monday, 12 August 2019 5:22 AM To: risoflora/brookframework Cc: glenswada; Mention Subject: Re: [risoflora/brookframework] HTTPServer under linux 64 Ubuntu (#9)

Hello @glenswada https://github.com/glenswada .

weighttp -n 10000 -t 5 -c 5 http://192.168.0.57:1080

I'm not familiar with weighttp, however, it seems the above line performs c10k https://en.wikipedia.org/wiki/C10k_problem test.

For such situations, you should configure the server for high-demand. For example:

BrookHTTPServer1.ThreadPoolSize := ; BrookHTTPServer1.ConnectionLimit := 10000; // for C10K situation

On Linux, you can get the using:

$ getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1

Please try those configurations and let me know if it solves the problem.

- You are receiving this because you were mentioned. Reply to this email directly, view https://github.com/risoflora/brookframework/issues/9?email_source=notificat ions&email_token=AM3XFIM5CNQHH42Q4CI2W4TQEBREVA5CNFSM4IKY45G2YY3PNVWWK3TUL52 HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BG7MY#issuecomment-520253363 it on GitHub, or mute https://github.com/notifications/unsubscribe-auth/AM3XFILXRZCD5ASCDCJW7TTQE BREVANCNFSM4IKY45GQ the thread. https://github.com/notifications/beacon/AM3XFIN3VV5FLBE27ZBDJB3QEBREVA5CNFS M4IKY45G2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BG7MY .gif

glenswada commented 5 years ago

I have been testing BrookHttpServer again with threadpoolsize =4 and connecriononlimit=10000

Running weighttp -n 10000 -t 5 -c 5 http://192.168.0.57:1080 http://192.168.0.57:1080/

The transaction results have increased to 11773 req/s with threadpoolsize increase.

By the third run of weighttp, BrookHttpServer starts slowing dramatically until it fails (connection failures) .. error: "connect() failed: Cannot assign requested address (99)"

I have also run BrookhttpServer on UDOO X86 running linux mate which performed better than nginx. Returning 8816 req/s against nginx 6500 req/s. On the UDOO X86 the BrookhttpServer started to slow down to 2000 req/s by third run but never failed to return requests.

Thanks Glen


From: silvioprog [mailto:notifications@github.com] Sent: Monday, 12 August 2019 5:22 AM To: risoflora/brookframework Cc: glenswada; Mention Subject: Re: [risoflora/brookframework] HTTPServer under linux 64 Ubuntu (#9)

Hello @glenswada https://github.com/glenswada .

weighttp -n 10000 -t 5 -c 5 http://192.168.0.57:1080

I'm not familiar with weighttp, however, it seems the above line performs c10k https://en.wikipedia.org/wiki/C10k_problem test.

For such situations, you should configure the server for high-demand. For example:

BrookHTTPServer1.ThreadPoolSize := ; BrookHTTPServer1.ConnectionLimit := 10000; // for C10K situation

On Linux, you can get the using:

$ getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1

Please try those configurations and let me know if it solves the problem.

- You are receiving this because you were mentioned. Reply to this email directly, view https://github.com/risoflora/brookframework/issues/9?email_source=notificat ions&email_token=AM3XFIM5CNQHH42Q4CI2W4TQEBREVA5CNFSM4IKY45G2YY3PNVWWK3TUL52 HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BG7MY#issuecomment-520253363 it on GitHub, or mute https://github.com/notifications/unsubscribe-auth/AM3XFILXRZCD5ASCDCJW7TTQE BREVANCNFSM4IKY45GQ the thread. https://github.com/notifications/beacon/AM3XFIN3VV5FLBE27ZBDJB3QEBREVA5CNFS M4IKY45G2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4BG7MY .gif

silvioprog commented 5 years ago

Hi Glen, thanks for reporting the tests.

I have been trying to reproduce the problems in a Raspberry Pi 3B+ with openSUSE Tumbleweed, but I couldn't get the fails you reported, however, I would like to reproduce them, because I must provide detailed steps for the GNU community explaining how to raise the fails (and possibly sending fix).

Could you reproduce the same problems in any virtual machine and share how you did it? (maybe emulating UDOO?)

glenswada commented 5 years ago

I have also tried against a virtual machine running win64 which takes 10 runs of "weighttp -n 10000 -t 5 -c 5 192.168.0.57:1080" before getting connection failures.

All I have done is run HTTPServer_Example in Linux Mint virtual machines and pound it with "weighttp -n 10000 -t 5 -c 5 192.168.0.57:1080". The Udoo X86 is also running Linux Mint but I will be getting an odroid N2 next week and planning to install Armbian, so will test it against that to see if it's OS specific.

Thanks glen


From: silvioprog [mailto:notifications@github.com] Sent: Wednesday, 21 August 2019 12:53 PM To: risoflora/brookframework Cc: glenswada; Mention Subject: Re: [risoflora/brookframework] HTTPServer under linux 64 Ubuntu (#9)

Hi Glen, thanks for reporting the tests.

I have been trying to reproduce the problems in a Raspberry Pi 3B+ with openSUSE Tumbleweed, but I couldn't get the fails you reported, however, I would like to reproduce them, because I must provide detailed steps for the GNU community explaining how to raise the fails (and possibly sending fix).

Could you reproduce the same problems in any virtual machine and share how you did it? (maybe emulating UDOO?)

- You are receiving this because you were mentioned. Reply to this email directly, view https://github.com/risoflora/brookframework/issues/9?email_source=notificat ions&email_token=AM3XFIJ6FVRLPRI4WZNPU53QFSUXFA5CNFSM4IKY45G2YY3PNVWWK3TUL52 HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4YILUY#issuecomment-523273683 it on GitHub, or mute https://github.com/notifications/unsubscribe-auth/AM3XFIM3FXDYV3IUSRFRL4DQF SUXFANCNFSM4IKY45GQ the thread. https://github.com/notifications/beacon/AM3XFIIUFO7FEMPOPAYT56DQFSUXFA5CNFS M4IKY45G2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4YILUY .gif

glenswada commented 5 years ago

I got my odroid N2 delivered last week. Had Ubuntu already installed so tried compiling libsagui-2.4.0 but failed as below. ..


--

/home/glen/libsagui-2.4.0/src/sg_str.c:62:9: error: invalid argument type

  'va_list' (aka '__builtin_va_list') to unary expression

if (!ap)

    ^~~

1 error generated.


--

But I was able to run weighttp from the odroid against Udoo x86. Result No slowdown

So I ran weighttp from the odroid against my I7. Result No slowdown

It seems that when I run weighttp directly from my i7 against other machines (virtual or otherwise) there is a slowdown

This slowdown doesn't occur from the I7 when testing against nginx for some reason. But it does imply the problem is with the configuration of weighttp on my I7 and not the Sagui library.

My apoligies for wasting your time on this.

Can you close the issue

Thanks Glen

Ps.. I am guessing your libsagui.so.2.4.0 from openSUSE wouldn't work under ubuntu. If it might can you send me a copy. I would like try get my odroid working as a webserver.


From: silvioprog [mailto:notifications@github.com] Sent: Wednesday, 21 August 2019 12:53 PM To: risoflora/brookframework Cc: glenswada; Mention Subject: Re: [risoflora/brookframework] HTTPServer under linux 64 Ubuntu (#9)

Hi Glen, thanks for reporting the tests.

I have been trying to reproduce the problems in a Raspberry Pi 3B+ with openSUSE Tumbleweed, but I couldn't get the fails you reported, however, I would like to reproduce them, because I must provide detailed steps for the GNU community explaining how to raise the fails (and possibly sending fix).

Could you reproduce the same problems in any virtual machine and share how you did it? (maybe emulating UDOO?)

- You are receiving this because you were mentioned. Reply to this email directly, view https://github.com/risoflora/brookframework/issues/9?email_source=notificat ions&email_token=AM3XFIJ6FVRLPRI4WZNPU53QFSUXFA5CNFSM4IKY45G2YY3PNVWWK3TUL52 HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4YILUY#issuecomment-523273683 it on GitHub, or mute https://github.com/notifications/unsubscribe-auth/AM3XFIM3FXDYV3IUSRFRL4DQF SUXFANCNFSM4IKY45GQ the thread. https://github.com/notifications/beacon/AM3XFIIUFO7FEMPOPAYT56DQFSUXFA5CNFS M4IKY45G2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4YILUY .gif

silvioprog commented 5 years ago

Hi Glen.

...
      'va_list' (aka '__builtin_va_list') to unary expression
...

Could you test latest version from trunk? It was fixed some days ago in https://github.com/risoflora/libsagui/commit/a1c372a8c0457d06500a9030bc8e70385982eaa4.

glenswada commented 5 years ago

Thanks for that, Fully compiled.

Just for fun I tested the odroid with weighttp from my I7, no slowdown at all. The little Odroid N2 with BrookFramework is responding at 5257 req/s which is outstanding given the odroid is only consuming 3.2 watts of power whilst performing the tests.

Just a heads up, when nginx forwarded packets to BrookFramework app on the odroid N2, the app asked for opensslsockets library to be installed (under x86 it was not the case). In listing opensslsockets I also had to apt install libssl-dev. I was not using https protocol but it wasn't a bother anyways.

Thank You. - very pleased :-)

glen


From: silvioprog [mailto:notifications@github.com] Sent: Wednesday, 4 September 2019 12:36 PM To: risoflora/brookframework Cc: glenswada; Mention Subject: Re: [risoflora/brookframework] HTTPServer under linux 64 Ubuntu (#9)

Hi Glen.

... 'va_list' (aka '__builtin_va_list') to unary expression ...

Could you test latest version from trunk? It was fixed some days ago in risoflora/libsagui@ https://github.com/risoflora/libsagui/commit/a1c372a8c0457d06500a9030bc8e70 385982eaa4 a1c372a.

- You are receiving this because you were mentioned. Reply to this email directly, view https://github.com/risoflora/brookframework/issues/9?email_source=notificat ions&email_token=AM3XFINCYLAMZZXEQULSWULQH4NHLA5CNFSM4IKY45G2YY3PNVWWK3TUL52 HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD52EP5A#issuecomment-527714292 it on GitHub, or mute https://github.com/notifications/unsubscribe-auth/AM3XFIIGTHK5WHS2VRHQGADQH 4NHLANCNFSM4IKY45GQ the thread. https://github.com/notifications/beacon/AM3XFIPX4SE3CERGPTKJKHLQH4NHLA5CNFS M4IKY45G2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD52EP5A .gif

glenswada commented 5 years ago

"Just a heads up, when nginx forwarded packets to BrookFramework app on the odroid N2, the app asked for opensslsockets library to be installed (under x86 it was not the case). In listing opensslsockets I also had to apt install libssl-dev. I was not using https protocol but it wasn't a bother anyways."

Ignore above comment from previous message, kust realized its coming from something in the arm build of Lazarus, another program that isn't brook is coming up with same opensslsockets message.


From: silvioprog [mailto:notifications@github.com] Sent: Wednesday, 4 September 2019 12:36 PM To: risoflora/brookframework Cc: glenswada; Mention Subject: Re: [risoflora/brookframework] HTTPServer under linux 64 Ubuntu (#9)

Hi Glen.

... 'va_list' (aka '__builtin_va_list') to unary expression ...

Could you test latest version from trunk? It was fixed some days ago in risoflora/libsagui@ https://github.com/risoflora/libsagui/commit/a1c372a8c0457d06500a9030bc8e70 385982eaa4 a1c372a.

- You are receiving this because you were mentioned. Reply to this email directly, view https://github.com/risoflora/brookframework/issues/9?email_source=notificat ions&email_token=AM3XFINCYLAMZZXEQULSWULQH4NHLA5CNFSM4IKY45G2YY3PNVWWK3TUL52 HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD52EP5A#issuecomment-527714292 it on GitHub, or mute https://github.com/notifications/unsubscribe-auth/AM3XFIIGTHK5WHS2VRHQGADQH 4NHLANCNFSM4IKY45GQ the thread. https://github.com/notifications/beacon/AM3XFIPX4SE3CERGPTKJKHLQH4NHLA5CNFS M4IKY45G2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD52EP5A .gif

silvioprog commented 2 years ago

Hey guys, since it is not a Brook related problem, I'm going to close, but feel absolutely free to reopen if you find any problem in Brook. 😉