Question

I have serious issue with custom foxx application.

About the app

The application is customized algorithm for finding path in graph. It's optimized for public transport. On init it loads all necessary data into javascript variable and then it traverse through them. Its faster then accessing the db each time.

The issue

When I access through api the application for first time then it is fast eg. 300ms. But when I do absolutely same request second time it is very slow. eg. 7000ms.

Can you please help me with this? I have no idea where to look for bugs.

Was it helpful?

Solution

Without knowing more about the app & the code, I can only speculate about reasons.

Potential reason #1: development mode.

If you are running ArangoDB in development mode, then the init procedure is run for each Foxx route request, making precalculation of values useless. You can spot whether or not you're running in development mode by inspecting the arangod logs. If you are in development mode, there will be a log message about that.

Potential reason #2: JavaScript variables are per thread

You can run ArangoDB and thus Foxx with multiple threads, each having thread-local JavaScript variables. If you issue a request to a Foxx route, then the server will pick a random thread to answer the request. If the JavaScript variable is still empty in this thread, it may need to be populated first (this will be your init call). For the next request, again a random thread will be picked for execution. If the JavaScript variable is already populated in this thread, then the response will be fast. If the variable needs to be populated, then response will be slow.

After a few requests (at least as many as configured in --server.threads startup option), the JavaScript variables in each thread should have been initialized and the response times should be the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top