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

chore(server): Set keep-alive and headers timeouts on server start #333

Conversation

ikoenigsknecht
Copy link
Contributor

No description provided.

@goldcaddy77
Copy link
Owner

Thanks for the PR! I already expose the httpServer on Server object, so you could do the following:

import { Server } from 'warthog';

const app = new Server();
app.start();
app.httpServer.keepAliveTimeout = keepAliveTimeout;
app.httpServer.headersTimeout = headersTimeout;

Do you know if most folks change these values from the defaults? If so, your change probably makes sense.

@ikoenigsknecht
Copy link
Contributor Author

ikoenigsknecht commented Apr 9, 2020

That's what we are currently doing and setting those values stopped our random 502 issue. It's also what we do elsewhere at Indigo. I'm not sure if this is what everyone does but 30s+ has been standard everywhere I've worked. My goal was to make it simpler and easier for others to avoid the same performance problems that we encountered.

src/core/config.ts Outdated Show resolved Hide resolved
src/core/config.ts Outdated Show resolved Hide resolved
src/core/server.ts Outdated Show resolved Hide resolved
src/core/server.ts Outdated Show resolved Hide resolved
WARTHOG_VALIDATE_RESOLVERS: 'false'
WARTHOG_VALIDATE_RESOLVERS: 'false',
WARTHOG_KEEP_ALIVE_TIMEOUT_MS: 30000,
WARTHOG_HEADERS_TIMEOUT_MS: 5000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think since you changed this to not be an offset, we'd need to set this to a value larger than WARTHOG_KEEP_ALIVE_TIMEOUT_MS, right?

In looking at these pages:

It seems both of these values need to be > 60. Should we do something like 61000 and 62000?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more about headersTimeout > keepAliveTimeout. 30s is a good keep alive (though if you want it to be 60s by default I can certainly make that change), but the key part of this is to ensure that the headers time out is greater than the keep alive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed up the change to make headers timeout 60s, that was an oversight in my last commit.

@goldcaddy77
Copy link
Owner

Looks great, thanks 👍

@goldcaddy77 goldcaddy77 merged commit 2cbc1a1 into goldcaddy77:master Apr 14, 2020
@ikoenigsknecht ikoenigsknecht deleted the fix/keep-alive-and-headers-timeouts branch April 14, 2020 13:00
@goldcaddy77
Copy link
Owner

🎉 This PR is included in version 2.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants