R
Railway•2y ago
mushuw

NodeJS server does not use connection keep-alive anymore

I moved my NodeJS http server from Heroku to NodeJS. It's just a school project, so it uses regular http (not https). Immediately, I noticed that API calls were slower, and upon inspecting the Network tab, I saw that the API calls do not use keep-alive anymore. I attempted to remedy this by specifying the timeout server.keepAliveTimeout = 60 * 1000; but that did not force add the header. I lack the intuition / experience to debug this any further. Does anyone have any ideas on the issue? project id: d5be23c8-4764-482f-aed7-f83c6e8007a2
2 Replies
Percy
Percy•2y ago
Project ID: d5be23c8-4764-482f-aed7-f83c6e8007a2
mushuw
mushuw•2y ago
Nevermind, I debugged it. Lots of things learned: 1. Localhost uses http/1.1 so it uses the keep-alive header 2. Postman on localhost also uses http/1.1 3. Browsers use http/2 or http/3 so they don't use keep-alive 4. Railway's free-tier vCPU is slower than Heroku's free-tier vCPU 5. When testing for performance, test on the deployed version... not localhost 😄