rgrinberg / opium

Sinatra like web toolkit for OCaml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docs on how to fork a server?

mudrz opened this issue · comments

commented

are there any docs to refer to on how to run opium on multiple processes?

for example this httpaf implementation forks the process n times based on nproc:

https://github.com/TechEmpower/FrameworkBenchmarks/blob/0bd0b6ad86a21cd0c54dc310d522962530a0c91f/frameworks/OCaml/httpaf/httpaf_unix.ml#L156-L174

this has had ~10x performance difference, so wondering what is a good starting step

commented

added some implementation, but it would be great if you could take a look if it makes sense:
https://github.com/TechEmpower/FrameworkBenchmarks/pull/6163/files

I didin't have a close look, but it seemed fine to me. To me, this should be the job of the tcp server to provide the preforking implementation.

#239 Added a function App.run_multicore that will spawn multiple processes with the Opium app. Let me know if that works for you @mudrz 🙂

commented

thanks @tmattio will check it out;
fyi the last run of tfb framework benchmarks includes the multi process forking:

https://www.techempower.com/benchmarks/#section=test&runid=b46d6bcb-6e29-434a-84db-5b9ded7cb198&hw=ph&test=db&l=zik0zj-67&a=2&f=4zsoy-jz6rk1-4zsp2-e8-3k-9hk-of09q8-cnk-cqo-hra0hs-3475-0

opium-fedora-forks - process forking running on fedora
opium-alpine-forks - process forking running on alpine
opium-haproxy - run opium on different ports and use haproxy to distribute the load (tbh performance is so bad, that there's likely something wrong with the config, I'll likely remove these tests)
opium - single process server

gist - multi process performance is 10x better than single process;

tbh I haven't tried running multi-process servers in prod, usually we run simply multiple instances and use a reverse proxy like nginx/haproxy/envoy to distribute the load