Hi, we’re using Oracle JDK’s Nashorn in a web application, where it is used to render HTML markup in HTTP worker threads.
I remember having read somewhere that the creation of a ScriptEngine (i.e. invocation of ScriptEngineFactory.getScriptEngine()) may have considerable performance overhead, so probably it should be avoided to do this with every incoming HTTP request. This is why we’ll go for keeping a ScriptEngine per thread in a ThreadLocal. On the other hand this may result in a large memory footprint, as there can be 200 HTTP worker threads, but we don’t have any experience with it yet. The ScriptEngineFactory.getParameter() Javadocs<http://docs.oracle.com/javase/8/docs/jdk/api/nashorn/jdk/nashorn/api/scripting/NashornScriptEngineFactory.html#getParameter-java.lang.String-> does list some interesting parameters for the key „THREADING“, that seem to make it possible to have a singleton ScriptEngine instead, which could be used concurrently from multiple threads. However, I have no clue whether this is either supported by Nashorn, nor how to set this parameter on engine creation. Is there per chance some recommended usage pattern for ScriptEngine in a web server? Thanks for any insights, Jörg --- Dipl. Inf. Jörg von Frantzius, Technical Director E-Mail joerg.frantz...@aperto.com Phone +49 30 283921-0 Fax +49 30 283921-29 Aperto AG - In der Pianofabrik Chausseestraße 5, D-10115 Berlin http://www.aperto.com<http://www.aperto.de/> http://www.facebook.com/aperto https://www.xing.com/companies/apertoag HRB 77049 B, AG Berlin Charlottenburg Vorstand: Dirk Buddensiek (Vorsitzender), Kai Großmann, Stephan Haagen, Daniel Simon Aufsichtsrat: Bernd Hardes (Vorsitzender)