diff --git a/content/admin-processes.md b/content/admin-processes.md index bef71e6..3ae04ee 100644 --- a/content/admin-processes.md +++ b/content/admin-processes.md @@ -1,5 +1,5 @@ ## XII. Admin processes -### One-off admin/management tasks +### Run admin/management tasks as one-off processes The [process formation](/concurrency) is the array of processes that are used to do the app's regular business (such as handling web requests) as it runs. Separately, developers will often wish to do one-off administrative or maintenance tasks for the app, such as: diff --git a/content/backing-services.md b/content/backing-services.md index a4179df..e632a82 100644 --- a/content/backing-services.md +++ b/content/backing-services.md @@ -5,7 +5,7 @@ A *backing service* is any service the app consumes over the network as part of Backing services like the database are traditionally managed by the same systems admintrators as the app's runtime deploy. In addition to these locally-managed services, the app may also have services provided and managed by third parties. Examples include SMTP services (such as [Postmark](http://postmarkapp.com/)), metrics-gathering services (such as [New Relic](http://newrelic.com/) or [Loggly](http://www.loggly.com/)), binary asset services (such as [Amazon S3](http://aws.amazon.com/s3/)), and even API-accessible consumer services (such as [Twitter](http://dev.twitter.com/), [Google Maps](http://code.google.com/apis/maps/index.html), or [Last.fm](http://www.last.fm/api)). -**The code for a twelve-factor app makes no distinction between local and third party services.** To the app, both are backing services, accessed via a URL or other locator/credentials stored in the [config](/config). A [deploy](/codebase) of the twelve-factor app should be able to swap out a local MySQL database with one managed by a third party (such as [Amazon RDS](http://aws.amazon.com/rds/)) without any changes to the app's code. Similarly, a local SMTP server could be swapped with a third-party SMTP service (such as Postmark) without code changes. In both cases, only the resource handle in the config needs to change. +**The code for a twelve-factor app makes no distinction between local and third party services.** To the app, both are attached resources, accessed via a URL or other locator/credentials stored in the [config](/config). A [deploy](/codebase) of the twelve-factor app should be able to swap out a local MySQL database with one managed by a third party (such as [Amazon RDS](http://aws.amazon.com/rds/)) without any changes to the app's code. Likewise, or a local SMTP server could be swapped with a third-party SMTP service (such as Postmark) without code changes. In both cases, only the resource handle in the config needs to change. Each distinct backing service is a *resource*. For example, a MySQL database is a resource; two MySQL databases (used for sharding at the application layer) qualify as two distinct resources. The twelve-factor app treats these databases as *attached resources*, which indicates their loose coupling to the deploy they are attached to. diff --git a/content/build-release-run.md b/content/build-release-run.md index fe958c7..9beb1b4 100644 --- a/content/build-release-run.md +++ b/content/build-release-run.md @@ -1,5 +1,5 @@ ## V. Build, release, run -### Strict separation of build stage and run stage +### Strictly separate build and run stages A [codebase](/codebase) is transformed into a (non-development) deploy through three stages: diff --git a/content/dependencies.md b/content/dependencies.md index c7ab9c4..9bfd33b 100644 --- a/content/dependencies.md +++ b/content/dependencies.md @@ -1,5 +1,5 @@ ## II. Dependencies -### Explicit dependency declaration and isolation +### Explicitly declare and isolate dependencies Most programming languages offer a packaging system for distributing support libraries, such as [CPAN](http://www.cpan.org/) for Perl or [Rubygems](http://rubygems.org/) for Ruby. Libraries installed through a packaging system can be installed system-wide (known as "site packages") or scoped into the directory containing the app (known as "vendoring" or "bundling"). diff --git a/content/dev-prod-parity.md b/content/dev-prod-parity.md index ac19b78..b7236bc 100644 --- a/content/dev-prod-parity.md +++ b/content/dev-prod-parity.md @@ -1,17 +1,17 @@ ## X. Dev/prod parity ### Keep development, staging, and production as similar as possible -Historically, there is a substantial gap between development (a developer making live edits to a local [deploy](/codebase) of the app), staging (a near-clone of the production deploy for doing dry runs of new releases), and production (a running deploy of the app accessed by end users). Gaps manifest in three areas: +Historically, there have been substantial gaps between development (a developer making live edits to a local [deploy](/codebase) of the app) and production (a running deploy of the app accessed by end users). These gaps manifest in three areas: * **The time gap:** A developer may work on code that takes days, weeks, or even months to go into production. * **The personnel gap**: Developers write code, ops engineers deploy it. * **The tools gap**: Developers may be using a stack like Nginx, SQLite, and OS X, while the production deploy uses Apache, MySQL, and Linux. -**The twelve-factor app is designed for [continuous deployment](http://www.avc.com/a_vc/2011/02/continuous-deployment.html)** by minimizing all three: +**The twelve-factor app is designed for [continuous deployment](http://www.avc.com/a_vc/2011/02/continuous-deployment.html) by keeping the gap between development and production small.** Looking at the three gaps described above: -* The time gap is small: a developer may write code and have it deployed hours or even just minutes later. -* The personnel gap is small: developers who wrote code are closely involved in deploying it and watching its behavior in production. -* Thus, it follows that the tools gap between development and production environments should also be made small. +* Make the time gap small: a developer may write code and have it deployed hours or even just minutes later. +* Make the personnel gap small: developers who wrote code are closely involved in deploying it and watching its behavior in production. +* Make the tools gap small: keep development and production as similar as possible. Summarizing the above into a table: diff --git a/content/disposability.md b/content/disposability.md index 870cff1..e19bb94 100644 --- a/content/disposability.md +++ b/content/disposability.md @@ -1,14 +1,14 @@ ## IX. Disposability -### Fast startup and graceful shutdown maximize robustness +### Maximize robustness with fast startup and graceful shutdown -The twelve-factor app's [processes](/processes) are *disposable*, meaning they can be started or stopped at a moment's notice. This facilitates fast elastic scaling, rapid deployment of [code](/codebase) or [config](/config) changes, and robustness of production deploys. +**The twelve-factor app's [processes](/processes) are *disposable*, meaning they can be started or stopped a moment's notice.** This facilitates fast elastic scaling, rapid deployment of [code](/codebase) or [config](/config) changes, and robustness of production deploys. -Processes should strive to minimize startup time. Ideally, a process takes a few seconds from the time the launch command is executed until the process is up and ready to receive requests or jobs. Small startup time provides more agility for the [release](/build-release-run) process and scaling up; and it aids robustness, because the process manager can more easily move processes to new physical machines when warranted. +Processes should strive to **minimize startup time**. Ideally, a process takes a few seconds from the time the launch command is executed until the process is up and ready to receive requests or jobs. Small startup time provides more agility for the [release](/build-release-run) process and scaling up; and it aids robustness, because the process manager can more easily move processes to new physical machines when warranted. -Processes shut down gracefully when they receive a [SIGTERM](http://en.wikipedia.org/wiki/SIGTERM) signal from the process manager. For a web process, graceful shutdown is achieved by ceasing to listen on the service port (thereby refusing any new requests), allowing any current requests to finish, and then exiting. Implicit in this model is that HTTP requests are short (no more than a few seconds), or in the case of long polling, the client should seamlessly attempt to reconnect when the connection is lost. +Processes **shut down gracefully when they receive a [SIGTERM](http://en.wikipedia.org/wiki/SIGTERM)** signal from the process manager. For a web process, graceful shutdown is achieved by ceasing to listen on the service port (thereby refusing any new requests), allowing any current requests to finish, and then exiting. Implicit in this model is that HTTP requests are short (no more than a few seconds), or in the case of long polling, the client should seamlessly attempt to reconnect when the connection is lost. For a worker process, graceful shutdown is achieved by returning the current job to the work queue. For example, on [RabbitMQ](http://www.rabbitmq.com/) the worker can send a [`NACK`](http://www.rabbitmq.com/amqp-0-9-1-quickref.html#basic.nack); on [Beanstalkd](http://kr.github.com/beanstalkd/), the job is returned to the queue automatically whenever a worker disconnects. Lock-based systems such as [Delayed Job](https://github.com/collectiveidea/delayed_job#readme) need to be sure to release their lock on the job record. Implicit in this model is that all jobs are [reentrant](http://en.wikipedia.org/wiki/Reentrant_%28subroutine%29), which typically is achieved by wrapping the results in a transaction, or making the operation [idempotent](http://en.wikipedia.org/wiki/Idempotence). -Processes should also be robust against sudden death, in the case of a failure in the underlying hardware. While this is a much less common occurrence than a graceful shutdown with `SIGTERM`, it can still happen. A recommended approach is use of a robust queueing backend, such as Beanstalkd, that returns jobs to the queue when clients disconnect or time out. Either way, a twelve-factor app is architected to handle unexpected, non-graceful terminations. [Crash-only design](http://lwn.net/Articles/191059/) takes this concept to its [logical conclusion](http://couchdb.apache.org/docs/overview.html). +Processes should also be **robust against sudden death**, in the case of a failure in the underlying hardware. While this is a much less common occurrence than a graceful shutdown with `SIGTERM`, it can still happen. A recommended approach is use of a robust queueing backend, such as Beanstalkd, that returns jobs to the queue when clients disconnect or time out. Either way, a twelve-factor app is architected to handle unexpected, non-graceful terminations. [Crash-only design](http://lwn.net/Articles/191059/) takes this concept to its [logical conclusion](http://couchdb.apache.org/docs/overview.html). diff --git a/content/logs.md b/content/logs.md index 8422854..7559269 100644 --- a/content/logs.md +++ b/content/logs.md @@ -1,5 +1,5 @@ ## XI. Logs -### Logs are event streams +### Treat logs as event streams *Logs* provide visibility into the behavior of a running app. In server-based environments they are commonly written to a file on disk (a "logfile"); but this is only an output format. diff --git a/content/port-binding.md b/content/port-binding.md index 00cdca8..ed1a4b1 100644 --- a/content/port-binding.md +++ b/content/port-binding.md @@ -1,5 +1,5 @@ ## VII. Port binding -### Services exported via port binding +### Export services via port binding Web apps are sometimes executed inside a webserver container. For example, PHP apps might run as a module inside [Apache HTTPD](http://httpd.apache.org/), or Java apps might run inside [Tomcat](http://tomcat.apache.org/). diff --git a/content/processes.md b/content/processes.md index 94bbe69..2f03f83 100644 --- a/content/processes.md +++ b/content/processes.md @@ -1,5 +1,5 @@ ## VI. Processes -### Stateless processes handle application logic +### Execute the app as one or more stateless processes The app is executed in the execution environment as one or more *processes*. diff --git a/content/toc.md b/content/toc.md index 0503e9a..fc2ede4 100644 --- a/content/toc.md +++ b/content/toc.md @@ -5,7 +5,7 @@ The Twelve Factors ### One codebase tracked in revision control, many deploys ## [II. Dependencies](/dependencies) -### Explicit dependency declaration and isolation +### Explicitly declare and isolate dependencies ## [III. Config](/config) ### Store config in the environment @@ -14,25 +14,25 @@ The Twelve Factors ### Treat backing services as attached resources ## [V. Build, release, run](/build-release-run) -### Strict separation of build stage and run stage +### Strictly separate build and run stages ## [VI. Processes](/processes) -### Stateless processes handle application logic +### Execute the app as one or more stateless processes ## [VII. Port binding](/port-binding) -### Services exported via port binding +### Export services via port binding ## [VIII. Concurrency](/concurrency) ### Scale out via the process model ## [IX. Disposability](/disposability) -### Fast startup and graceful shutdown maximize robustness +### Maximize robustness with fast startup and graceful shutdown ## [X. Dev/prod parity](/dev-prod-parity) ### Keep development, staging, and production as similar as possible ## [XI. Logs](/logs) -### Logs are event streams +### Treat logs as event streams ## [XII. Admin processes](/admin-processes) -### One-off admin/management tasks +### Run admin/management tasks as one-off processes