redis和postgresql一起开发,面对高并发写请求如何更新
ringa_lee
ringa_lee 2017-04-22 09:00:03
0
1
747

是用代码分别更新到redis和postgresql数据库(谁先谁后)还是只更新到redis,然后通过队列异步更新到数据库?如果有详细的做法更好,谢谢!PS:有人谁用过redis-fdw吗?

ringa_lee
ringa_lee

ringa_lee

reply all(1)
左手右手慢动作

If redis and the database are updated at the same time, it is actually a cache update strategy issue. Let me tell you my opinion, let’s consider it as a starting point:
Two strategies are commonly used for this type of problem:
1. Update when writing to the cache: This means that the cache is updated after the DB is written successfully. This strategy can reduce penetration, but it can easily cause data inconsistencies.
2. Update when reading the cache: This means that the cache is only deleted after the DB is written successfully, and the cache is rebuilt when it needs to be read. The consistency of this strategy can be guaranteed, but the penetration is large and can easily put pressure on the DB.

(After searching, I found that there are many cache update modes. The two mentioned above are just what I know of
1.Write-through Write immediately
2.Write-behind Write the cache first, put the write event into the Queue, and then write to the database
3. Eviction Policies Cache update policy directly deletes the data in the cache and waits for it to be updated the next time it is read.
4. Replication
5. Peer-To-Peer (P2P)
)

If you only update redis and then update it asynchronously to the database, it will be difficult to reconstruct the data after the cache is down. If your data does not need to be strictly accurate but needs to be accessed quickly, you can consider doing this, such as the number of page visitors.

redis-fdw has never been used.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template