While it may feel premature to start discussing production concerns at this point, you can save yourself a lot of time and suffering down the line if you start thinking about production early on: launch day will be here before you know it.
In this chapter, we’ll learn about Express’s support for different execution environments, methods to scale your website, and how to monitor your website’s health. We’ll see how you can simulate a production environment for testing and development, and also how to perform stress testing so you can identify production problems before they happen.
Express supports the concept of execution environments: a way to run your application in production, development, or test mode. You could actually have as many different environments as you want. For example, you could have a staging environment, or a training environment. However, keep in mind that development, production, and test are “standard” environments: Express, Connect, and third-party middleware may make decisions based on those environments. In other words, if you have a “staging” environment, there’s no way to make it automatically inherit the properties of a production environment. For this reason, I recommend you stick with the standards of production, development, and test.
While it is possible to specify the execution environment by calling
app.set('env', 'production'), it is inadvisable to do so: it means your app will always run in that ...