V
V
viig2021-08-19 16:22:49
Node.js
viig, 2021-08-19 16:22:49

Test question, scalable service?

Hello. This is the test task

Create a service that collect data from cryptocompare.com using its API and stores it in a database (MySQL/PostgreSQL/Mongo)
Example API request: GET https://min-api.cryptocompare.com/data/pricemultif ...

REQUIREMENTS:
1. Currency pairs must be configurable.
2. Database parameters must be configurable.
3. Service must store data in database by a scheduler.
4. If cryptocompare's api is not accessible service must serve data from its database.
5. API should accept as many fsyms/tsyms in one request as possible (ex.: GET service/price?fsyms=BTC,LINK,MKR&tsyms=USD,EUR,ETH,LTC should return all pair prices)
6. Data in response must be fresh (realtime). 2-3 minutes discrepancy is ok.
7. Service scalability is a plus.

In general, everything is clear, but there is a moment - what is meant by scaling, the seventh point? What kind of scaling can be here? Run multiple instances of a service that just polls a URL and saves data to a database, and serves a single API route?
And save to the database on schedule. Besides setInterval, what other solutions are there and what are their advantages.

Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
@
@insighter, 2021-08-19
@viig

It is possible that the implementation provides for quick refinement of the connection of other data sources.
In any case, most likely it was about functionality, not performance.

�
âš¡ Kotobotov âš¡, 2021-08-19
@angrySCV

Apparently your service is expected to scale.
there are several approaches for this:
for example, approaches related to "replication", that is, databases are simply duplicated, which allows you to speed up reading (writing because of this, on the contrary, will be slower, since synchronization of recording between copies is required),
and the second approach is "sharding", when different databases store different groups of data (for example, users from 1-1000 are stored and processed on server 1, from 1000 to 2000 on server 2, etc.).
there are more tricky approaches like smart caches.
Also, judging by point 4, some kind of "caching layer" is expected between your service and a third-party source of quotes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question