I've written a number of Perl clients using the Perl API and have done some profiling. I've found that the call to Search::Elasticsearch::new() can take more than 50% of the total execution time. I'd like to speed this up some how. Any suggestions?
One thought I had was to have a proxy application that keeps an instance of an ES object and then some how pass that object to my clients so they don't have to instantiate their own. Is that possible some how? Or maybe there's a better solution.
The Perl client uses Moo, which provides a lot of flexibility but does have a small start up cost. Typically most applications would create an instance once then reuse it many times. The same approach should be applied for pretty much all other Perl modules as well. Why are you creating new instances frequently?
I have a rather large and complex bash script which is used in one of our production systems. The bash script make many calls to the perl scripts. While I could reorganize the bash script and perl scripts so that only one call to a single perl script is made, this would be a significant change to our configuration and would move most of the functionality out of our current bash script. I was hoping there was some way to "save" the ES instance (may via Storable) so that each perl script doesn't have to instantiate their own. Or maybe have a proxy perl script daemon which can serve the ES instance to the individual scripts.