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

Use a mmap file to read data in StaticRoute #517

Merged
merged 7 commits into from
Oct 1, 2015

Conversation

jashandeep-sohi
Copy link
Contributor

When making use of the fallback sendfile method, a mmap file should be used to read the data to reduce memory usage.

Correct me if I'm wrong, but I believe reading data from a mmap file is better if you are running a web app on multiple processes. With a mmap file each process can share the memory pages, and thus save you some memory. This probably only true for large files.

@asvetlov
Copy link
Member

I think it's overoptimization.
Most likely in production configuration the code will be run on Linux with sendfile support (and behind nginx BTW).
Don't expect too much from mmap support.

@jashandeep-sohi
Copy link
Contributor Author

I'm sure there are countless schemes of serving up static content using other software, but I was strictly thinking from aiohttp's point of view rather than aiohttp + x.

But sendfile is useless in my case because I'm serving everything over SSL. I know I can do SSL termination at the load balancer, but I'd rather have each app do it's own crypto.

I'll do some benchmarks tonight to see if using mmap files makes any practical difference.

@asvetlov
Copy link
Member

SSL use case makes sense for PR, I've missed this.

@asvetlov
Copy link
Member

@jashandeep-sohi unfortunately GitHub doesn't send notification email if you just push new commits without a comment.
So I'm not aware about your work on the PR.

Do you think the current stage is ready for review?

@jashandeep-sohi
Copy link
Contributor Author

Well, I was trying to running some benchmarks yesterday with ab (Apache HTTP server benchmarking tool), but I encountered a possible bug with Keep-Alive connections so I got side-tracked with that. I'll make a new issue to discuss that.

As for this PR, the code is good, but I haven't profiled memory usage yet.

@jashandeep-sohi
Copy link
Contributor Author

Consider reviewing & merging.

@asvetlov
Copy link
Member

Please fix merge conflicts

@jashandeep-sohi
Copy link
Contributor Author

fixed

asvetlov added a commit that referenced this pull request Oct 1, 2015
Use a mmap file to read data in StaticRoute
@asvetlov asvetlov merged commit 5e714a9 into aio-libs:master Oct 1, 2015
@asvetlov
Copy link
Member

asvetlov commented Oct 1, 2015

Thanks

@lock
Copy link

lock bot commented Oct 30, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 30, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants