简体   繁体   English

在生产环境中使用 Sanic 的内置网络服务器

[英]Using Sanic's inbuilt webserver in Production

Django documentation states regarding their development server: Django文档说明了他们的开发服务器:

Don't use this server in anything resembling a production environment.不要在任何类似于生产环境的环境中使用此服务器。 It's intended only for use while developing.它仅供开发时使用。 (We're in the business of making Web frameworks, not Web servers.) (我们的业务是制造 Web 框架,而不是 Web 服务器。)

Sanic's deployment documentation do not say that we can not use it's built in server in production. Sanic 的部署文档并没有说我们不能在生产中使用它内置的服务器。 It states:它指出:

Deploying Sanic is very simple using one of three options: the inbuilt webserver, an ASGI webserver, or gunicorn.使用以下三个选项之一部署 Sanic 非常简单:内置网络服务器、ASGI 网络服务器或 gunicorn。 It is also very common to place Sanic behind a reverse proxy, like nginx.将 Sanic 置于反向代理之后也很常见,例如 nginx。

For me it means freedom from Apache.对我来说,这意味着从 Apache 中解放出来。 It also means that Nginx, Gunicorn, Daphne, Uvicorn, Hypercorn etc. are optional.这也意味着Nginx、Gunicorn、Daphne、Uvicorn、Hypercorn等都是可选的。

However, I found some negative comments regarding its built in server in Sanic: python web server that's written to die fast .然而,我发现一些关于它在Sanic 中的内置服务器的负面评论: python web 服务器写得很快 On the other hand, Their github repository seems very active.另一方面,他们的 github 存储库似乎非常活跃。 Did they addressed the issues mentioned in the Reddit post?他们是否解决了 Reddit 帖子中提到的问题?

Am I missing something?我错过了什么吗?

Issue 1 deals with request size and timeout settings that allow for DoS attacks by flooding the server with too much data.问题 1 处理请求大小和超时设置,这些设置允许通过向服务器发送过多数据来进行 DoS 攻击。 These settings can be adjusted by the admin, according to the server hardware and the requirements of the site being run.管理员可以根据服务器硬件和正在运行的站点的要求调整这些设置。 That being said, the defaults probably should be lower than they are, to make such attacks on unconfigured servers more difficult.话虽如此,默认值可能应该低于它们的值,以使对未配置服务器的此类攻击更加困难。

Issue 2 claims that there is no backpressure handling in streaming responses.问题 2 声称流响应中没有背压处理。 The current version does have flow control and thus gets proper backpressure control, avoiding such issues.当前版本确实具有流量控制,因此可以获得适当的背压控制,避免此类问题。 Since this was quite badly overlooked in Python's asyncio protocol design, a lot of applications had such problems in the past, presumably also including Sanic at the time the blog was written.由于这在 Python 的 asyncio 协议设计中被严重忽视了,过去很多应用程序都存在这样的问题,大概在写博客的时候也包括 Sanic。

As it is now, the Sanic server can certainly run directly on Internet, and that is in fact much safer against DoS than running Django behind nginx or Apache, where any long-lasting POST request blocks an entire Django worker. As it is now, the Sanic server can certainly run directly on Internet, and that is in fact much safer against DoS than running Django behind nginx or Apache, where any long-lasting POST request blocks an entire Django worker.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM