search

Home  >  Q&A  >  body text

mysql读写同步实现思路

场景是这样的的:A程序从远程接口定期的读数据并进行分析存储到数据库中,B程序提供外部接口来访问数据库中的数据。有可能B在读数据的时候,A在写数据,这样不就乱套了吗?如何保证read和write不发生冲突?对mysql的表进行加锁吗?还是有其他的实现思路?

PHP中文网PHP中文网2768 days ago468

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 14:19:19

    1. Reading and writing are not conflicting. It’s just that the data being written may not be read when reading, or the complete data must be read after the writing is completed. Please check the concept of things
    2. Reading and writing conflicts? There are read and write conflicts in the same table, unless it is guaranteed that it cannot be read when writing, then the myisam engine can handle it. Check the concept of table locks
    3. In terms of things, there is no conflict between reading and writing, unless you are a big For data and the like, consider nosql. Otherwise the innodb engine is enough.

    reply
    0
  • Cancelreply