My team has been experimenting with I18n::Backend::KeyValue as an alternative to the Simple backend that comes packaged by default with Rails. We have been trying out using different key-value stores, such as RocksDB and BerkeleyDB. We have two main goals: 1) reduce Ruby process memory by storing translated strings externally, rather than in memory as the Simple backend does; and 2) improve startup time by pre-seeding the key-value store with the translated strings, rather than reading/parsing the YAML files at startup as the Simple backend does.
This seemed like a great idea, but in practice we’ve hit some snags. Mainly, the available_locales method and the translations method of the KeyValue store are both very slow.
I noticed that documentation for KeyValue does state that available_locales is slow, and you should avoid calling it on a KeyValue backend. However, since we are planning to use KeyValue as the primary backend, in our case it doesn’t seem reasonable to simply avoid calling this method. We would probably need to call it eventually.
I also noticed that the implementation of KeyValue#translations basically reads the contents of the key-value store into a Hash. This seems to mean that we wouldn’t actually get any memory savings by using KeyValue, because eventually at some point the translations would be read into memory anyway.
Does anyone have experience using KeyValue as their primary I18n backend?