I want to make bottle
python web service to serve binary files like pdf, picture and exe with authentication.
Is it possible to serve all this files using bottle? I have hard time finding a tutorial for that.
How about the performance
? Does bottle python handle hundreds of thousands downloads simultaneously?
I am planning to use it with nginx
uwsgi
.
It is definately possible to serve these files using bottle. You simply serve them as static files. As far as authentication goes, I do not believe bottle comes with authentication support ( as far as I know ). When it comes to performance though, this is an area when it really depends on how you deploy it. In a regular threaded environment, where each request gets it's own regular thread, I highly doubt your server will be able to comfortably serve hundreds of thousands of requests at the same time. However, it is noted in the documentation, that greenlets
may be able to let you overcome this issue.
Bottle static file serving: http://bottlepy.org/docs/dev/tutorial.html#routing-static-files
Bottle greenlets: http://bottlepy.org/docs/dev/async.html#greenlets-to-the-rescue
If you are not in a hurry i suggest you to try uWSGI 1.9 (it is still in development but the first stable release will be in 10 days) and use offload-threads = n (set it to the number of cpus). In that way when you send a file from your app it will be asynced (and non blocking) served by a different thread, suddenly freeing your worker. Offloading is available in 1.4 too but it is not automatic for apps as in 1.9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With