Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pre-forking on Unix #239

Merged
merged 6 commits into from
Dec 8, 2020
Merged

Implement pre-forking on Unix #239

merged 6 commits into from
Dec 8, 2020

Conversation

tmattio
Copy link
Collaborator

@tmattio tmattio commented Dec 4, 2020

This PR borrows code from https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/OCaml/opium/src that forks the process to spawn multiple instances of the Opium app.

The Opium command line now provides a -j/--jobs argument to set the number of instances that will be spawn. It defaults to the number of cores on the host machine on Unix, and 1 on Windows.

Since we cannot nest calls to Lwt_main.run and to offer a unified API for multicore and single core, we lose the ability to return an Lwt.t from the run functions. But maybe there's another way to implement that I'm not seeing.

cc @mudrz

Fixes #222
Closes #207

@tmattio tmattio force-pushed the pre-fork branch 2 times, most recently from 65f11f9 to ed4d7e7 Compare December 4, 2020 17:12
@tmattio tmattio merged commit 29eb6f1 into rgrinberg:master Dec 8, 2020
@tmattio tmattio deleted the pre-fork branch December 8, 2020 22:19
tmattio added a commit to tmattio/opam-repository that referenced this pull request Dec 9, 2020
CHANGES:

## Added

- New `Auth` module to work with `Authorization` header (rgrinberg/opium#238)
- New `basic_auth` middleware to protect handlers with a `Basic` authentication method (rgrinberg/opium#238)
- New `Response.of_file` API for conveniently creating a response of a file (rgrinberg/opium#244)
- Add a package `opium-graphql` to easily create GraphQL server with Opium (rgrinberg/opium#235)
- Add a function `App.run_multicore` that uses pre-forking and spawns multiple processes that will handle incoming requests (rgrinberg/opium#239)

## Fixed

- Fix reading cookie values when multiple cookies are present in `Cookie` header (rgrinberg/opium#246)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs on how to fork a server? opium in techempower frameworks benchmarks
1 participant