2 Rails applications utilizing 1 MySQL database - what are the risks?
ENVIRONMENT:
Ubuntu hardy LTS, Apache 2, Passenger Virtual Server One: rails 2.3.8 application accessing MySQL common_database Virtual Server Two: rails 3.0.4 application accessing the same MySQL common_databaseThe first application gets regular use from our clients. The second application is released but seeing light usage currently. The database seems to be working fine.
Someone advised me that this configuration could wind up corrupting the database. We anticipate that the second application will eventually get heavy usage. It would kill some momentum if the database became co开发者_如何学运维rrupted. A few more facts:
- Neither application has the ability to change database structure.
- Both apps will be accessing the same tables at the same time.
- It is impossible for both apps to attempt to update the same record at the same time.
Has anyone experienced corruption of a MySQL database that is accessed in this kind of configuration? Were you able to overcome the problem? How?
What was the case made for risk of corruption?
As long as you aren't using rake db:migrate and both apps have the same models, you have roughly the same risks as if two or more web servers with the same application version have been spun up. If there is a divergence in expectation of what the database schema looks like between the two apps, you may run into issues, especially if the divergence is related to foreign keys, or application logic that is based on magic values.
With any concurrent manipulation of a database you run into a category of issues around modifying the same records simultaneously (who wins when two clients try to modify the same piece of data; what kind of locking model do you use, etc).
精彩评论