0

We are building a vernacular application in which we need to show the information/content to the user based on the language selected by user. Currently we support English and 10 regional languages.

The data is static(gets changed but less frequently) but we still needs to serve it from the backend based on the input header : APP_LANGUAUGE : EN in the api-calls, we get from the client.

We initially thought that the simplest way to do this is, we can store the constants for all languages supported, on the app config files and based on the language header, we can serve that language constants. We can't store in DB (as DB will cost us the 'select' query time and thus increases the app loading times, we really don't want that as well).

Is there a better place(backend data-store) to save the values for these constants (for all the languages supported) for instance in zookeeper. How would you make the trade-off here between config files or zookeeper or any other config server ? These values are not going to get changed very frequently but does change some times.

tusharRawat
  • 719
  • 10
  • 24

1 Answers1

1

Which amount of data do you have?

Looks like you could safe the constants in a file and load them on app start in your local heap space e.g. in a Map, because they will be changed very rarely.

Of course you could use ehcache or other key-value stores as well.

Johann Kexel
  • 133
  • 1
  • 8
  • Are you asking for size of data. Currently they are just 30-40 strings properties for each language. So 10 (language) *30 = 300 properties approx. Data size is small currently. – tusharRawat Feb 10 '23 at 20:23
  • ```Looks like you could safe the constants in a file```. You mean to say the current approach of keeping them in config files and load them in memory when app gets started. – tusharRawat Feb 10 '23 at 20:26
  • yes, I meant the data size. Looks like it's not that much with ~300. You are right my solution is not that far away from yours. So I would stick to either your config file solution or mine extra file with cache. Imo an extra service like zookeeper is too much effort, because you still have to run it and make the communication resilient. – Johann Kexel Feb 11 '23 at 19:50
  • Should we externalize the values from the application code, like adding them in the config file as placeholder and reading the values from config server. – tusharRawat Feb 11 '23 at 21:58
  • One benefit I can see with zookeeper is, when any value gets changed, we don't have to take the deployment. As application will read those dynamically as in zookeeper we have watches – tusharRawat Feb 12 '23 at 09:10
  • Everything has its own advantages and disadvantages. It always depends on your business and quality requirements. If you for example can deploy on demand and it takes under an hour, then you don't need to change it dynamically. – Johann Kexel Feb 12 '23 at 12:43
  • Like I understood, the translations is some kind of content you serving to the different users. It feels not as the right place saving that content in a config file or on a config server(separation of concerns). The advantage with a dedicated translation file is, that you could exchange them in the filesystem and let your app watch the directory for changes. – Johann Kexel Feb 12 '23 at 12:56
  • Right, but building this system like you are saying, watching changes in a filesystem whenever it change, will require effort from the application side as well, Which is provided default out of the box by zookeeper with the help of Watches. – tusharRawat Feb 12 '23 at 13:01
  • Like I said: pros/cons... It's not my intent to convince you. It sounds to me just like taking a sledgehammer to crack a nut. (To run zookeeper implies you need a replicated mode in prod. Hence a quorum of at least 3 instances is needed. Then you need some kind of pipeline for deploying/starting the zookeeper including the whole infra stuff as (technical) users and access rights configurations. Then you need to handle zookeeper in your app and implement the resilience stuff. How would the content get onto the zookeeper? Is there a versioning strategy for the content? No need to answer) – Johann Kexel Feb 12 '23 at 21:24