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

Improve TCP communication #15

Merged
merged 2 commits into from
Feb 1, 2019
Merged

Improve TCP communication #15

merged 2 commits into from
Feb 1, 2019

Conversation

hltbra
Copy link
Contributor

@hltbra hltbra commented Jan 31, 2019

I saw some issues when I was running stress tests against an EC2 server and realized that I did a terrible job with the TCP communication in the previous releases.

The proper way (copied from Redis) is to ignore half-baked messages and buffer them instead of expecting the communication to have everything ready to go.

The changes in server.py aren't covered by tests because I couldn't replicate this issue locally, even with https:/sitespeedio/throttle.

A chunk is read from the network and added to a buffer (recv()),
then if the buffer doesn't have enough information, the handler
waits for the next `handle_read` call to get more information into the buffer.
This works with simultaneous clients.

The Redis codebase was the guide for this commit.
Sometimes with non-blocking sockets they can receive EAGAIN,
this is for extra safety and to avoid unnecessary crashes
@hltbra hltbra added the bug Something isn't working label Jan 31, 2019
@hltbra hltbra merged commit ce0d0f8 into master Feb 1, 2019
@hltbra hltbra deleted the bugfix/tcp-reads branch February 1, 2019 20:59
hltbra added a commit that referenced this pull request Feb 1, 2019
* Improve TCP communication (#15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant