Nginx importance in production was normally based on its ability to serve slow clients; In the setup of RESTful API it seems to be an unnecessary layer to the production stack, especially as Puma (unlike the widely used unicorn can handle nginx work).
Puma can allow multiple slow clients to connect without requiring a worker to be blocked on the request transaction. Because of this, Puma handles slow clients gracefully. Heroku recommends Puma for use in scenarios where you expect slow clients. ref
How to enable Puma to serve multiple ruby applications on the same port without using nginx as a reverse proxy?
You can't, Puma is an application server.
On the TCP/IP stack each application gets assigned to a port so that a received packet can be proxied to the application that's expecting it. Imagine that multiple applications live on the same port: There would be no way for an application to know if the receiving packet is really intended for it or for another application on the same port.
That's why we use proxies and reverse proxies. Nginx, being a reverse proxy, resolves the requested URL to an application and proxies the request to it. It's a single application that receives all incoming packets on a given port and then proxies them to an application on another port or socket.
To have multiple web servers on the same port you would have to have a reverse proxy such as Nginx or HAproxy in-front of them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With