2

I try to solve my problem about architecture of application which is based on node.js. I have some ideas but I'm wondering about your thoughts.

well, my application will be stored activities from customer websites, activities which will be defined by customer, eg. login on website, click on product, click on the category menu etc. These events will be pass to my application and after that, I show actitivities to customer dashboard for analytics or for another purpose.

First of all I think about sending request by ajax from websites to my server and after parsing data on my node.js server, send that data to dashboard account via socket.io. The user will see every event from him website on dashboard "on the flight". Do you think that concept is ok? Does every ajax request will not be too much costly ? Maybe I should think about another way to send data to my server?

enter image description here

corey
  • 300
  • 1
  • 16

1 Answers1

2

You are trying to design classic analytical application which assembles data from different sources and shows some analytics upon this data like Google Analytic and so on.

Does every ajax request will not be too much costly? 
Maybe I should think about another way to send data to my server?

For web applications that’s standard way to send data from client to server. Of course, Http protocol has more overheads comparing to UDP, WebSockets or protocols upon them but it doesn’t need additional security configurations, easy to use and scale. WebSockets require keeping TCP connection all the time and is harder to scale. You can find many post about comparison these protocols like here.

According to this question your app is going to be a proxy of events from web sites to another web apps where them will be analyzed somehow. Every event will have some information like type (login, click), url, user, date and so on. It can work up to some loading. Apparently, you will have problems on browser side accepting more 100 events (requests) per second even via WebSockets. JS with single-thread execution model is not so good for analytics (filtering, calculation, aggregation). I think you don’t need to pass events to dashboard as they are, it would be more useful to send some aggregated data like new events count, event histograms and so on. So, in this case you need to perform analytics on backend side (node.js app).

I recommend you also to look at CQRS approach where storing data (events) and their retrieve (query) is separated in order to achieve good performance for both write (log events) and read (retrieve events or some analytics) operations. Apparently you may need to use some database to do analytics like Mondo DB, maybe Redis and so on.

Vasyl Zvarydchuk
  • 3,789
  • 26
  • 37