I have the web application that provides user with the interface to edit its character. When user makes some changes and saves them, I store it as delta in MongoDB. UI and backend communicate via REST.

But in addition, I want to store any change that user made on UI - like clicking the button, or updated some parameter without saving yet. Something akin a separate mechanism that tracks user actions.

Will REST suffice for that? Or will it lead to spam of REST requests? Because user or multiple users may do a lot of changes thus it will lead to multiple REST calls.

2 Answers 2


Yes, you see this commonly with heatmap generation and marketing tools for websites.

As the processing power for each request is small, simply an insert, a webserver can easy handle lots of requests.

If you could choose your protocol you might go for UDP rather than HTTP over TCP, but you are limited by having to have your code run in a browser over the internet

  • so REST is way to go? I thought Websockets or something else will be faster.
    – lapots
    Apr 4, 2019 at 8:46
  • Websockets seems more appropriate than REST API Webs. You are not transferring/managing resource's state representations and you either are navigating through a hierarchy of resources. You are rather sending small bits of information to the server, asynchronously, continuously without the need for feedback. Fire-and-forget.
    – Laiv
    Sep 2, 2019 at 11:43
  • conceptually websockets is good. but i think it would be impractical for this kind of mass tracking. Whether an API that accepts the actions over http is 'truely RESTful' is a bit academic for me. http api that accepts json == REST
    – Ewan
    Sep 2, 2019 at 11:48

If you are worried about network load you could simply buffer events locally and send them in a batch. You would need some logic of when to send the buffer, like when saving the form, when the buffer is full, or after some time. You might not be guaranteed that all events are sent, but for gathering usage statistics it might not matter. This should probably reduce the overhead quite a bit since you would be sending fewer but larger requests.

If REST is sufficient would greatly depend on how many users you have, what kind of infrastructure you would be using etc.

You might also chose to gather such information from some subset of users, since the marginal value of a sample will be reduced the more samples you have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.