Performance improvement: Pub/sub should pass messages by reference
emadum opened this issue · 3 comments
Messaging systems work best with small message payloads. Redis in particular suffers huge performance losses when pub/sub message payloads get large.
Since UMF messages already have a unique message ID, we can cache the message payload in redis when a message is sent and only send the message ID over pub/sub, minimizing the message payload.
My gut tells me there is a "cutoff" in payload size where doing this makes sense but just keeping the message in the payload makes sense to avoid another trip to Redis for EvERY message. I can't imagine too many messages being passed that the receiver doesn't need the payload for it to actually do work. So, that process would need to fetch the payload from Redis (somehow?)
This is fine for LARGE payloads but I think for smaller ones (TBD but maybe 1K or less?) it maybe more efficient to just pass the payload itself. This is just a hunch from 30+ years of doing things like this. :)
Or -- perhaps I am missing the whole point. LOL
Yes you're 100% right. We did a little benchmarking of this PR and that quickly became obvious.
I've been busy lately, but plan on doing some more benchmarking using 1k, 5k and 10k message size cutoffs.