我目前正在开发一个 iOS 应用程序,需要一个后端来提取数据。我使用 Python、web.py 和 pymongo 实现了后端。
我在 EC2 实例上部署了所有内容,为 iOS 设备调用以访问后端的实例分配了一个弹性 IP,并通过以下操作通过 SSH 启动应用程序:
nohup python main.py &
一切正常(每天几十个用户,有可能增长;数据传输的数据很少超过几千字节),但我想知道这是否是正确的处理方法。
例如,在 web.py 网站上,他们解释了如何将 web.py 与 Apache、lightppd 等一起使用;这些只是特殊情况,还是我应该使用其中一台功能齐全的服务器来部署我的后端?
I am currently developing an iOS application that needs a backend to pull data from. I have implemented the backend using Python, web.py and pymongo.
I deployed everything on an EC2 instance, assigned an elastic IP to the instance that the iOS devices call to access the backend, and launch the application through SSH by doing:
nohup python main.py &
Everything works fine (couple dozen users a day, with potential to grow; data transferred is rarely more than a few kilobytes), but I'm wondering if this is the proper way to do things.
For instance on the web.py website, they explain ways to use web.py with Apache, lightppd etc.; are these just special cases, or should I be deploying my backend using one of those full featured servers?
发布评论
评论(2)
FWIW,我们在 CherryPy (“内置于”web.py 的网络服务器) ://nginx.org/" rel="nofollow">nginx 为 Oyster.com 提供大部分 HTML —— nginx 将流量分配到 2 或 3 个 Web 服务器,每个服务器运行 4 个 Python 进程,我们可以轻松处理数百个每秒请求数。
但是,我们对图像和 CSS 等静态资源使用内容交付网络 (CDN)。
FWIW, we use CherryPy (the web server "built into" web.py) behind nginx to serve most of the HTML at Oyster.com -- nginx splits the traffic across 2 or 3 web servers each running 4 Python processes, and we can easily handle 100s of requests per second.
However, we use a content delivery network (CDN) for our static resources like images and CSS.
我绝对会使用完整的 Web 服务器,而不是 web.py 中内置的服务器,尽管如果流量仍然很低,那么现在应该没问题。我认为 web.py 中内置的应该用于调试,而不是生产。
这主要是您使用哪一个服务器的偏好问题,但我喜欢 Nginx 和 uWSGI。
I would absolutely use a full web server rather than the one built into web.py, although you should be okay for now if the traffic remains low. I think the one built into web.py is supposed to be used for debugging, rather than production.
It's mostly a matter of preference which of those servers you use, but I like Nginx with uWSGI.