d-mozulyov / NetBenchmarks

17 stars 5 forks source link

Node.js Client Gives Wrong results #4

Open synopse opened 2 years ago

synopse commented 2 years ago

The client code has several limitations, as reported by https://components4developers.blog/2021/11/02/http-middleware-benchmarks:

It turns out that the Node.js client benchmark actually do create the number of connections, but it will never execute a request on all of them at any time. Well… with a limited number of cores that will always be the case, but Node.js seems to be limiting it further. I suspected the client benchmark code to be a bottleneck in it self, not really providing the means to really exercise the HTTP servers.

I also noticed that the Work processing in the Node.js client is also resource consuming - more than on the server side for sure (at least for GoLang and mORMot RTTI).

The numbers reported by components4developers are not the same as your numbers. I guess it comes from problems on the client side.

My guess is that rewriting the client in Delphi is needed.

d-mozulyov commented 2 years ago

Hello! Thank you very much for not staying indifferent!

I completely agree with you. Moreover, now I am gradually trying to create a benchmark in Delphi in a separate branch feature/iocp_bench

It is important to say the following. The point of the project is not to test HTTP. We also need to test network solutions on other protocols: UDP, TCP, WebSocket, Pipe. Now I am looking for a high-performance asynchronous library, on the basis of which all benchmarks can be created. Can you advise the IOCP client library/class/sample ?

synopse commented 2 years ago

There is no such agnostic library AFAIK.

But I would focus on HTTP and WebSockets. For several reasons.

Note that WebSockets is a frame protocol, not a query/answer protocol, so it is not directly REST compatible - what we did with mORMot is create a JSON and a Binary WebSockets protocol to encapsulate REST request from both client and server sides: but it is not standard. There is no such standard, because it was not the point of WebSockets.

We have an asynchronous TCP layer for clients in mORMot 2: https://github.com/synopse/mORMot2/blob/master/src/net/mormot.net.async.pas You may also consider https://github.com/grijjy/DelphiScalableClientSockets

d-mozulyov commented 2 years ago

It seems to me that the value of this performance pivot table is not only that the network libraries are compared, but the protocols as well. For example, there is a lot of controversy about the justification of the pipe. Many are experimenting with or using UDP, including Google. Some people choose between TCP, HTTP and WebSocket. This table will be able to objectively show the overall picture, taking into account the protocol, library and payload factor.

At the moment I am looking at these libraries: https://github.com/winddriver/Delphi-Cross-Socket https://github.com/ymofen/diocp-v5 https://github.com/tondrej/iocp-delphi

d-mozulyov commented 2 years ago

@synopse

Hey

I am currently experimenting with IOCP (feature/iocp_bench branch). I want to do all benchmarks (TCP, UDP, Pipe, WebSocket, HTTP) through this technology. A very strange thing is happening now - WSASend gives error 10038, as if the operation was not on a socket, although the socket is being created and the connection is successful.

Could you look at the code and suggest why the error might occur?

It is easy to reproduce the error. First, you need to start the HTTP server, for example, Indy.HTTP.exe, then in debug run the benchmark.HTTP.dproj project, the Debug-NoProcess configuration.