简体   繁体   中英

Rails application puma server

I am creating a chat application (using puma server with max thread count 20 and wen concurrency 5). In this application the message after being sent by the user that gets saved and appends at receivers side through socket. But if the user types more messages faster the messages order changes. How to get saved the records in an order

If you're using push / polling technologies (SSE / WebSockets / AJAX) to receive chat data, consider adding a millisecond based timestamp to the messages.

This will allow you to order the messages on the client side using the exact timestamp built to each message and prevent message ordering issues.

Also, minimizing the server processing time per message will minimize scheduling issues.

This includes choosing a faster technology / solution as well as increasing concurrency or separating the database storage "event" from the "push" event handling scheme (which is usually unnecessary and less ideal, but it does offer higher reaction time).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM