7 ms·
You could solve the resource starvation issue by running multiple instances of your app and binding to a port using the SO_REUSEPORT option. This will allow mul
by doorman2 4y ago
You could solve the resource starvation issue by running multiple instances of your app and binding to a port using the SO_REUSEPORT option. This will allow multiple instances of your app to use the same port.
This option is also quite good for deployments as you can have instances stop reading from the port while client traffic is still being served from other instances on the port. This works well for HTTP requests, but less so for something like gRPC.
- commitpizza 4y agoJust out of curiosity, how would you configure that in a systemd configuration file?
- doorman2 4y agoYou use the setsockopt system call. This is an example in C: int sfd = socket(domain, socktype, 0); int optval = 1; setsockopt(sfd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)); bind(sfd, (struct sockaddr *) &addr, addrlen); In Go, you can use syscall.SetsockoptInt. Most languages have a way of setting this option. You have to create the socket yourself and pass it into your HTTP server in most cases, but it depends on the library. Edit: oh sorry, you meant when systemd is opening the port for you. It looks like you can set ReusePort=yes in your configuration? https://www.freedesktop.org/software/systemd/man/systemd.socket.html https://www.freedesktop.org/software/systemd/man/systemd.soc...
- jbaczuk 4y agowhy not just build multithreading into deno? Is this only a paid feature?