hi, im developping high-performance libev's event-loop multi-thread web server.
this: mofuw_ev
but, when exec
wrk -c 1000 http://localhost:8080
get nil error...
when the load becomes large, the server drops due to an error.
but, i dont know where the error is occurring.
im creating a web server for the first time, it may be wrong somewhere on my code.
can help me ? thx.
You need some coding discipline, your code is full of unsafe code, every line in there would need to be carefully reviewed to prove it correct. Worst offender is maybe code like this
watcher.async.add(cast[ptr ev_async](ev_async.new())) # GC is free to free this object whenever it want to, ``ptr``'s are not traced
Why not use Nim's asynhttpserver? ;-)
yep... that code is very bad sorry x(
approach of the model as the Web server was wrong, this cord deletes it now!
Why not use Nim's asynhttpserver?
answer is simple.
because, i want to make fast web server. its just my hobby.
i think AsyncHTTPServer is a bit slow... ah, this does not mean that AsyncHTTPServer is bad.
when I create a web application I will use AsyncHTTPServer ;) that great web server tool.
i made a Web server with AsyncDispatcher alone to see the performance of AsyncDispatcher.
it was about 1.5 times faster than AsyncHTTPServer.
i have not seen all the internal code of AsyncHTTPServer, but I expected that the parser is probably a bottleneck.
assume that requests received from clients are temporarily saved in variables.
better parsers will not allocate memory in the process of parsing the request.
for example, like picohttpparser
i needed such a fast parser to make a fast web server.
the resulting parser is this mofuparser
since it is zero copy, even when parsing 100, 000 times, the request parsing ends in about 0.05 seconds. (CPU: Intel core 2Duo T7700 2.40GHz 3 Core)
also, by using libuv to create multithreaded event loops, a web server with considerable performance was completed.
... talk is wrong
AsyncHTTPServer is not bad, rather a wonderful tool.
i dont know a lot about async, but i think the async of Nim will become better in future.
thank you for splendid language, Araq :)
(sorry if wrong because im weak in English! ; _ ; )