Locking and Redis

后端 未结 2 522
野性不改
野性不改 2021-02-03 11:28

We have 75 (and growing) servers that need to share data via Redis. All 75 servers would ideally want to write to two fields in Redis with INCRBYFLOAT operations. W

相关标签:
2条回答
  • 2021-02-03 12:03

    Since Redis is single threaded, you will probably want to use master-slave replication to separate writes from reads, since yes, writes will generally block reads.

    Alternatively you can consider using Apache Zookeeper for this, it provides reliable cluster coordination without single points of failure (like single Redis instance).

    0 讨论(0)
  • 2021-02-03 12:05

    Redis does not lock. Also, it is single threaded; so there are no race conditions. Reads or Writes do not block.

    You can run millions of INCRBYFLOAT on the same key without any problems. No need for external processes. Reading those fields does not pose any problems.

    That said, "Millions of updates to two keys" sounds strange. If you can explain your use case, perhaps there might be a better way to handle it within Redis.

    0 讨论(0)
提交回复
热议问题