github facebook twitter

Using Reuse Port for Multiple Kemal Processes

require "kemal"

get "/" do
  "Reusing port 3000"
end do |config|
  server = config.server.not_nil!
  server.bind_tcp "", 3000, reuse_port: true

You can use the following script to spawn multiple Kemal processes according to your CPU cores.


for i in $(seq 1 $(nproc --all)); do


Important: This is for demonstration purpose only. You should use a mature process manager / monitor for production.

Source Code