Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SaveMessagesAndIncrNextSenderMsgSeqNum in MessageStore #555

Open
Yu-Xie opened this issue Apr 27, 2023 · 0 comments
Open

Support SaveMessagesAndIncrNextSenderMsgSeqNum in MessageStore #555

Yu-Xie opened this issue Apr 27, 2023 · 0 comments

Comments

@Yu-Xie
Copy link

Yu-Xie commented Apr 27, 2023

Today, MessageStore persist message to send one by one through this method:

SaveMessageAndIncrNextSenderMsgSeqNum(seqNum int, msg []byte) error

This means each outgoing message maps to one database operation. This is less efficient when there is traffic spikes.
I did a benchmark using SQL Store, with local laptop and Postgres in Docker. If you send out X outgoing messages all at once by calling SendToTarget, the results are listed below (which is very slow because we write to database for every single message without batching at all):

  • 100 Messages = 204 ms (490 QPS)
  • 1000 Messages = 1568 ms (638 QPS)
  • 5000 Messages = 8294 ms (602 QPS)
  • 10000 Messages = 15712 ms (636 QPS)

The proposal is to support batching for outgoing messages:

  1. Support a bulk method func SaveMessagesAndIncrNextSenderMsgSeqNum(seqNum int, msg [][]byte) in the storage interface.
  2. Support a bulk method func SendAppToTarget(m []Messagable, sessionID SessionID) error in registry.go which invokes 1. underneath.

Prototype is done in this PR #576 with SQLStore and In Memory Store support (not file store / mongo store yet).

@ackleymi @mgatny What do you think?

@Yu-Xie Yu-Xie changed the title Support BatchSaveMessageAndIncrNextSenderMsgSeqNum in MessageStore Support SaveMessagesAndIncrNextSenderMsgSeqNum in MessageStore Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant