Design principles twelve factors SasS

Heroku is the industry's leading cloud application platform, to provide services since they already have experience in hosting and operating millions of applications. Its founder Adam Wiggins Based on these experiences, issued a "Declaration of twelve elements of the application (The Twelve-Factor App)", this design principle is very instructive to SaaS platform.

Twelve elements of a declaration application


Today, software is usually delivered as a service, they are known as network applications, or software as a service (SaaS). 12-Factor methodology provides a SaaS application was constructed as follows:

  • Automatic configuration using standardized processes, so that new developers to learn the cost of the least expensive to join the project.
  • And between the operating system to draw the boundaries as much as possible, providing maximum portability in each system.
  • Suitable for deployment in modern cloud computing platform, thereby saving server resources and systems management.
  • The differences in development and production environments to minimize the use of continuous delivery and implementation of agile development.
  • Expansion can be achieved under the premise of tools, architecture and development process is not a significant change.

This theory applies to any language and back-end service applications (databases, message queues, buffers, etc.) development.

12-factor for building Web applications or SaaS platform very useful guidelines, but it is not suitable for micro-service system in some places. Therefore, modifications and extensions of the 12-factor in the implementation of micro-service architecture, the core idea of ​​"second factor is applied" in the universal micro-service architecture applied for continuous delivery and optimization.

Micro Services twelve factors applied

1-- code number: a code number, multiple deployment

Twelve-Factor App recommend a code library for each application. In the micro-service architecture, the correct method is actually a code base for each service. In addition, we strongly recommend using Git as a repository, because of its rich feature set and a huge ecosystem. GitHub has become the default Git hosting platform open source community, but according to the needs of your organization, there are many other excellent Git hosting options.

2 - Dependencies: explicitly declare dependencies

As The Twelve-Factor App suggested in it, whether your application is running on which platform you have to use language or framework that comes with dependency manager. How do you install the operating system or platform dependence depends on the platform:

In non-integrated environment to install the system configuration management tools using dependencies (Chef, Puppet, Ansible).
In a container of the environment, you do this in the Dockerfile.
Note: We recommend that you choose to rely on management mechanism, rather than as a separate decision under the overall infrastructure that is code for policy background.

3 - Configuration: Configuration stored in the environment

The difference between any deployment can be considered a configuration. Twelve-Factor App Guide recommends that in the environment, rather than submit it to the repository of all configuration storage. We recommend the following specific practices:

.Env non-use file version control for local development. Docker support load these files at run time.
.Env all files are saved in a secure storage system (eg Vault) in order to make these documents available to development teams use, but will not submit to Git.
Anything that might change the run-time and should not be submitted to any shared content repository using environment variables.
After the application is deployed to the delivery platform, using the mechanism of delivery platform to manage the environment variables.


4 - Support Services: the back-end services as additional resources

Twelve-Factor App will guide support is defined as "as part of its normal operation, any service applications used on the network." Meaning that any micro-service content services are treated as additional external resources, including other services. This ensures that each service is completely portable, and loosely coupled to other resources in the system. In addition, strict separation will increase flexibility in the development process - developers only need to run their services being modified without the need to run other services.

5 - Build, distribute, run: strict separation of building and running

In order to support strict separation of build, publish and operational phases, we recommend using continuous integration / Continuous Delivery (CI / CD) tool to automatically build. Docker image can easily build and run separate stages. Ideally, the image is created from each submission, and is considered the deployment of the workpiece.

6 - Process: one or more stateless processes running applications

For micro-services, processes, factors important point is that your application needs stateless. This service can be easily extended by simply adding more service instances. Any data stored status data needs to be shared between instances of back-up services.

7-- data isolation: to provide services through the port binding

As the port binding factor for micro-services more useful modification is recommended only allowed to have persistent data access services through the API services. This prevents implicit contracts between micro-services, and to ensure that service can not be micro-tightly coupled. Data isolation also allows developers to select the most appropriate service for each type of data store their needs.

8 - concurrency: process model be extended by

Unix process model is largely a senior micro-services architecture, because it allows for specialization and resource sharing for different tasks in a single application. In the micro-services architecture, you can independently expand the level of each service, and within the scope of the underlying infrastructure support. Use of container service, you can get Twelve-Factor recommended application concurrency free.

9 - can be discarded: the quick start and termination of elegance to maximize robustness

Services instance requires a one-time use, so you can quickly start, stop and re-deployment, and without loss of data. Docker containers deployed in the service will automatically meet this requirement, because it is an inherent function of the container, you can stop and start them immediately. Or session state data is stored in a queue or other back-up services to ensure seamless crash occurs when the container is to process the request.

10 - Development / Product Parity: keep as development, pre-release, the same online environment

Keep all environments possible - the development stage, production, etc. - in order to reduce the risk of errors occur only in certain environments. To support this principle, we again recommend the use of container - here is a very powerful tool because they allow you to develop the whole production process from the local to run exactly the same execution environment. But remember, the differences in the underlying data still make a difference at runtime.

11-- Log: the log as event stream

Do not include the service in the micro-code or for routing logs are stored, and to use one of the many excellent market log management solutions, several factors listed in the twelfth application. In addition, decide how to use the log needs to be a greater part of APM and / or PaaS strategy.

12-- management processes: Manage tasks run as a one-time process

Application separate operational management and maintenance tasks. Container makes it very easy, because you can start a container to run a task, and then close it.

in conclusion

Twelve-Factor App is a methodology of building a micro-services SasS software. The best practice is to make an application to build deployed to the web in a production environment with the portability and flexibility. I hope you use these principles when developing your own applications, Twelve-Factor App and use these principles to help you create additional sustainable delivery, and application-optimized microprocessor-based services.

 

Guess you like

Origin www.cnblogs.com/liangsonghua/p/www_liangsonghua_me_36.html