I have a little experience developing REST APIs for accessing large amounts of similar resources. This post concerns storing single resources that are updated often.For example, I plan on creating an app for a radio station that shows different radio shows, their hosts, and their scheduled times. If I wanted you to also be able to see what music was currently playing on the station, I'm confused with how you might store the information about the currently playing song, as it gets updated at least every couple minutes.If I were to store the currently playing song in the database, the information for that song might be stored in a single table or collection with a single item that is being updated often. This does not seem like a very good solution in my head as making many database calls for a simple resource seems like unnecessary overhead.One other solution I briefly considered was simply storing the data in some local variable on the server side. This also doesn't seem like an optimal solution. If I understand correctly, if you were to scale horizontally with this solution, each of the different servers would potentially have a different version of this variable and therefore users may see different things.To solve this problem, I may be able to just have a file that the data is stored in that each server has access to. I'm not sure if this is a safe or efficient solution.I would likely use something like socket.io to inform the clients of the change of song so that their end is updated accordingly, but if the server were to crash, I'd still need some sort of persistent data source through which the server might access the last song that was playing.I understand that this is not exactly a Node-based issue, but I plan to develop, and have developed most of an API with, Node, and any suggestions of technologies or techniques specific to Node.js would be greatly appreciated. Thank you.
Submitted July 02, 2020 at 05:20AM by gungunthegun
No comments:
Post a Comment