
The implementation of the final web product is not the most pleasant procedure for the creator and is often accompanied by terrible stress. The developer's dislike for releases is associated not only with feelings of responsibility and fear of exploiting the new version, but also with feelings of uncertainty: what will happen after we introduce ourselves?
Applications can be developed by a large team of programmers, quality engineers, graphical interfaces, but at the end of the project path, the last of the Mohicans takes responsibility. The lack of theoretical knowledge makes our hero nervous, because the experience gained through trial and error, under the hour is not enough for a systematically successful implementation. To figure out how to roll out web projects into battle, let's start with the basics.
General Staff Plan

')
After receiving the requirements, specifications, various recommendations and instructions, the developer allocates space for his maneuvers in the source code repository. This area can be a personal SVN branch, a new module in CVS or a folder on the file system.
It makes no sense to talk in detail about the subsequent cycles of “Develop - Test - Deploy”: it is written about them and so many useful things. I will note only important observations:
- Each developer's application should use personal databases and file storages. Use a common "trash" - evil, causing serious errors.
- The development of autotests is not always justified : their implementation should not take more than 20% of the working time. Develop through testing - the extreme degree of waste.
- The more participants in the process, the more often it is necessary to merge and check the collective result. Continuous integration can help, but maintaining it can be expensive - you need to balance between automation and cost.
The final results of the development are recorded in the release candidate (the branches merge, a tag is created, etc.) and transferred to acceptance testing. A release candidate is an end-to-end monolithic product that cannot be modified. If you need to correct mistakes, refine the functionality, you need to start from the beginning and make a new candidate.
Hard to learn
It is worth noting that many managers conduct acceptance testing in the development environment, which is fundamentally wrong. It is clear that to make a separate candidate for nano-bugs is very lazy (and wasteful). But the procedure of introduction to the test platform, once worked out, will significantly save the developer time and nerves. Moreover, no one bothers to put small fixes into groups and fix them in one version of the product.
The main hints of acceptance testing:
- The scenario of the introduction of the candidate should be as close as possible to the scenario of the introduction of the release. If in the final release it is planned to update the database structure, migrate data, add third-party libraries - all this must be done in the sequence in which the release is supposed to be implemented.
- The test platform conditions should be as close as possible to the combat conditions. If the application uses a cluster of 5 memcached servers, prepare> 1 server on the test platform. If the application uses 1 DBMS master server in RW mode and 2 slave servers in RO mode, reconstruct the complete replication scheme. To save on equipment for testing distributed systems will help free VMWare Server (or any other equivalent, except Virtuozzo). Versions of system libraries, OS kernels, etc. should also coincide with the versions of the corresponding components of the combat platform.
- Load testing is a floating acceptance testing problem. It is impossible to completely recreate the release conditions: we do not know what the load will be exactly, we can only assume. Yes, and create a complete copy of the combat platform is expensive. For adequate testing, bottlenecks are usually identified in the application, their maximum stability values ​​are measured for them and the results are approximated to the expected loads.
- Testing should be regression , but you need to balance between quality and cost. If only cosmetic changes are made to the interface, it makes no sense to run the test plan completely.
- Do not forget to roll back the application , return to the previous version should be carefully worked out.
The transition from the candidate to the release may take a certain number of iterations "Candidate - Testing - Change". During the cycle, there will be new bugs, changing requirements and changes. Ultimately, you have to break the vicious circle and make a release. And it is extremely rare for a pre-release test report to be 100% complete (developers in such cases are otmazyvatsya prefix
beta ).
I once ruled the development of a portal about advertising. The team then had to roll out ~ 20 candidates before the release was introduced. The release was implemented from the 10th time. The final test report was successful at ~ 70%. Not the most successful project in my life.
To arms
The order of introduction of the release should be as follows:
- We introduce new versions of platform components . We update libraries, services, etc., while keeping the tool for rolling back to the old versions.
- We implement a DB and file storage . If the previous version of the application is working in combat, you need to prepare in advance the old release to support the new storage structure. The story is this:
- We add to the previous release support for a new storage scheme
- we introduce the changed previous release
- we introduce a new storage structure and migrate data (the previous release should work in the old logic with the new storage)
- introducing a new release
- We implement the application .
- Testing the application .
- Roll back (if necessary).
In the case of a fackup, we roll back to the previous version in the reverse order:
- Roll back the application .
- Roll back the database and file storage (if necessary).
- Roll back platform components (if necessary).
Application to battle
First, the application must be designed in such a way that its folder structure is separated from the file storage.
Right / var / www / myproject /
/ etc /
/ lib /
/ classes /
/ images /
/ templates /
index.php
/ var / www / userdata /
/ images /
/ video /
| Not properly / var / www / myproject /
/ etc /
/ lib /
/ classes /
/ images /
/ templates /
/ userdata /
/ images /
/ video /
index.php
|
Secondly, it is necessary to control versions of third-party libraries. To be sure that the supported version of the Zend Framework library is used in combat, you must either include the library in the folder structure of the application (and keep it in
svn ), or present the release as a package (for example,
deb ) with which to check dependencies.
Thirdly, many developers embed an application into battle with an update from the source code repository (
svn up ). This approach can only be
compared with
rm –rf / . The release must be completely removed from the repository and placed in a separate place from the previous release.
Releases are placed in separate folders on the battle platform. user @ stable: ~ / apps / myproject $ ls -la
drwxr-xr-x 12 user www-data 4096 Oct 29 11:38.
drwxr-xr-x 5 user www-data 4096 May 13 23:22 ..
drwxr-xr-x 8 user www-data 4096 Oct 22 17:11 rel_0.5.1
drwxr-xr-x 8 user www-data 4096 Oct 27 13:17 rel_0.5.1.1
drwxr-xr-x 8 user www-data 4096 Oct 28 02:07 rel_0.5.1.2
drwxr-xr-x 8 user www-data 4096 Oct 29 11:38 rel_0.5.2
user @ stable: ~ / apps / myproject $ svn co svn + ssh: //user@svn.myproject.ru/myproject/tags/rel_0.5.2.1
...
user @ stable: ~ / apps / myproject $ ls -la
drwxr-xr-x 12 user www-data 4096 Oct 29 11:38.
drwxr-xr-x 5 user www-data 4096 May 13 23:22 ..
drwxr-xr-x 8 user www-data 4096 Oct 22 17:11 rel_0.5.1
drwxr-xr-x 8 user www-data 4096 Oct 27 13:17 rel_0.5.1.1
drwxr-xr-x 8 user www-data 4096 Oct 28 02:07 rel_0.5.1.2
drwxr-xr-x 8 user www-data 4096 Oct 29 11:38 rel_0.5.2
drwxr-xr-x 8 user www-data 4096 Oct 29 12:31 rel_0.5.2.1
|
After extracting the source code, the project is installed (configurable configs, permissions, starting data) and tested next to a working release, for which a separate virtual web server host can be used (for example,
www-test.myproject.ru ). After running the test plan, the previous release is replaced by a new one. The following options for replacing releases are known: changing the symbolic link,
mount_null , changing the web server
config , followed by
graceful restart .
With a symbolic link we switch the project from one release to another. In the same way, you can roll back to the previous version. user @ stable: ~ / httpdocs / $ ls –la
drwxr-xr-x 3 user www-data 4096 Oct 29 11:40.
drwxr-xr-x 9 user www-data 4096 Oct 28 21:25 ..
lrwxrwxrwx 1 user www-data 27 Oct 29 11:40 pro -> ../apps/myproject/rel_0.5.2
user @ stable: ~ / httpdocs / $ rm pro && ln –s ../apps/myproject/rel_0.5.2.1 pro
user @ stable: ~ / httpdocs / $ ls –la
drwxr-xr-x 3 user www-data 4096 Oct 29 11:40.
drwxr-xr-x 9 user www-data 4096 Oct 28 21:25 ..
lrwxrwxrwx 1 user www-data 27 Oct 30 17:12 pro -> ../apps/myproject/rel_0.5.2.1
|
If the application is distributed:
- disable some backends by redirecting all traffic from the fronts to the remaining workers
- On disconnected backends we perform local implementations and tests.
- switching traffic to fresh backends
- repeat the procedure for the released backends
- As a result of block introduction, the front-ends are switched to the normal state and distribute the load across all backends.
The more servers are involved and the more complex the structure of the application, the greater the need for automation tools and implementation control. However, do not forget the favorite rule of futurologists: do not trust the robots - they were created by people who are prone to make mistakes.
PS If you have enough strength to finish the story, wait for the second part about the virtues of LiquiBase , the rsync pitfalls and the migration of file storages.
PPS In the course of correspondence with one of the habrayuser it was formulated: the main thing in this informational appeal is not to impose one's recommendations, but the fact that I make a person think about the problems that may arise in his particular situation. General recommendations on * ^ & no one needs. In the end, everyone makes their own way. And it is right. Because every project is unique.