I will explain firstly a usecase: Let us assume that I have a service e.g. a server which generates some data in form of a JSON object.
Server 1: {"id":1234, "timestamp":"2020-11-12"}
There is another server (server 2) which fetches the data occasionally. Maybe each second but maybe each 12 hours. Server 2 also adds new data to the JSON.
Server 2: {"id":1234, "timestamp":"2020-11-12", "my-new-data":"someHash"}
So now the question:
1. As I know how the resulting data will look like, shall I define it consistent from the beginning at Server 1?
--> Server 1: {"id":1234, "timestamp":"2020-11-12", "my-new-data":null}
Cons (while defining structure at each server the same):
- This way I may have huge JSON objects and while fetching very often I have more traffic, which could be in fact avoided.
- If JSON object changes, each server needs to be updated
- Dirty architecture?
Pros (while defining structure at each server the same):
- Consistency
- Cleaner architecture?
Which way would you choose and why? Do you differentiate over different usecases - e.g. small service, big service?
Aucun commentaire:
Enregistrer un commentaire