第十一章 部署到生成环境之前的准备工作
In this chapter, we will discuss the following topics:
在这一章,我们将讨论以下话题:
• Picking a web stack 挑选一个 web 服务
• Hosting approaches 托管方法
• Deployment tools 发布工具
• Monitoring 监控
• Performance tips 性能建议
So, you have developed and tested a fully functional web application in Django. Deploying this application can involve a diverse set of activities from choosing your hosting provider to performing installations. Even more challenging could be the tasks of maintaining a production site working without interruptions and handling unexpected bursts in traffic.
你已经使用 Django 开发并测试了完整功能的 web 应用。而部署这个应用就涉及到了选择你的主机托管服务商执行安装的一组各种不同的行为。甚至是更具挑战的维护生产环境中正在使用的网站,而不用中断它,并处理未被预料到到突发流量。
The discipline of system administration is vast. Hence, this chapter will cover a lot of ground. However, given the limited space, we will attempt to familiarize you with the various aspects of building a production environment.
系统管理员的规定是很多的。因此,本章覆盖的内容也很多。篇幅虽然所限,但是我们会试着让你尽可能多的熟悉构建生成环境的方方面面。
生成环境
Although, most of us intuitively understand what a production environment is, it is worthwhile to clarify what it really means. A production environment is simply one where end users use your application. It should be available, resilient, secure, responsive, and must have abundant capacity for current (and future) needs.
尽管,我们都大多数的人从直觉上都能够理解生产环境是个什么东西,但是在这里,值得我们花点时间来澄清生产环境的真正的意思。生产环境是一个多简单的终端用户可以使用你所开发的应用的地方。它应该是可用的、可还原的、安全的、灵活响应的、而且必须拥有当前(和未来)充足的扩展能力。
Unlike a development environment, the chance of real business damage due to any issues in a production environment is high. Hence, before moving to production, the code is moved to various testing and acceptance environments in order to get rid of as many bugs as possible. For easy traceability, every change made to the production environment must be tracked, documented, and made accessible to everyone in the team.
不同于开发环境,在生产环境中对现实业务的破坏所引发的任何问题都可能要付出非常高昂都代价。因此,在迁移到生产环境中之前,代码应该接受多种测试,和认可的环境中以尽可能多多去除 bug。简单来说,每个应用到生产环境中的变更都必须追踪、纪录、而且要然团队中任何人都能够理解。
As an upshot, there must be no development performed directly on the production environment. In fact, there is no need to install development tools, such as a compiler or debugger in production. The presence of any additional software increases the attack surface of your site and could pose a security risk.
Most web applications are deployed on sites with extremely low downtime, say, large data centers running 24/7/365. By designing for failure, even if an internal component fails, there is enough redundancy to prevent the entire system crashing. This concept of avoiding a single point of failure (SPOF) can be applied at every level—hardware or software.
Hence, it is crucial which collection of software you choose to run in your production environment.
选择 web 服务
So far, we have not discussed the stack on which your application will be running on. Even though we are talking about it at the very end, it is best not to postpone such decisions to the later stages of the application lifecycle. Ideally, your development environment must be as close as possible to the production environment to avoid the "but it works on my machine" argument.
By a web stack, we refer to the set of technologies that are used to build a web application. It is usually depicted as a series of components, such as OS, database, and web server, all piled on top of one another. Hence, it is referred to as a stack.
We will mainly focus on open source solutions here because they are widely used. However, various commercial applications can also be used if they are more suited to your needs.
栈的组件
A production Django web stack is built using several kinds of application (or layers, depending on your terminology). While constructing your web stack, some of the choices you might need to make are as follows:
生产环境中的 Django web 栈使用的是多种应用(或者层,视使用的术语不同而不同)。当构建 web 栈时,如下是你可能遇到当选择:
- Which and distribution? For exaple
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论