Is Realm fit to be used in situation where write frequencly?


#1

Hi, I’m new to Realm. Doc says that " Note that write transactions have a non-negligible overhead", and I’m developing a IM client, which means write could call for multiple times in one second due to chat happens vary often, is there any performance risk?


#2

I dont think that you can write in a chat app more than one message per second.
Maybe two if somebody write 1 character per message, but that is not a performance risk.


#3

Thanks for your reply, but there’s some difference.
To make it clear, we can use slack for example.
In one second, we will receive many messages from channels and users, these messages should be write at once. In that scene, write would call multiple times equals to how many messages we received in one second.


#4

But thats a read, not a write.

Dont count in the sync process, thats very optimised.


#5

I’m using Realm database only, not including Realm Sync, So I have to handle write myself, I need to write every messages I received in chat.


#6

@freeubi:
You will be plenty fine with few write transactions per second!
Just avoid writing a tight ‘for’ loop with thousands of transactions in a second. Just keep in mind that the overhead is non-zero when writing code to get the best responsiveness. For example (unless necessary) don’t do a write for every key-press for example, but wait for a field to be completed. Common sense stuff.


#7

@roberhofer Thank you, I’ll try that