简体   繁体   English

Arangodb foxx-应用性能不佳

[英]Arangodb foxx-application poor performance

I have serious issue with custom foxx application. 我有自定义foxx应用程序的严重问题。

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. 在init上,它将所有必要的数据加载到javascript变量中,然后遍历它们。 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. 当我第一次通过API访问应用程序时,它很快,例如。 300ms. 300毫秒。 But when I do absolutely same request second time it is very slow. 但是,当我第二次完全相同的请求时,它非常慢。 eg. 例如。 7000ms. 7000ms。

Can you please help me with this? 你能帮我解决这个问题吗? I have no idea where to look for bugs. 我不知道在哪里寻找bug。

Without knowing more about the app & the code, I can only speculate about reasons. 在不了解应用程序和代码的更多信息的情况下,我只能推测原因。

Potential reason #1: development mode. 潜在原因#1:发展模式。

If you are running ArangoDB in development mode, then the init procedure is run for each Foxx route request, making precalculation of values useless. 如果您在开发模式下运行ArangoDB,则会为每个Foxx路由请求运行init过程,从而使预先计算的值无效。 You can spot whether or not you're running in development mode by inspecting the arangod logs. 您可以通过检查arangod日志来发现您是否在开发模式下运行。 If you are in development mode, there will be a log message about that. 如果您处于开发模式,则会有相关的日志消息。

Potential reason #2: JavaScript variables are per thread 可能的原因#2:JavaScript变量是每个线程

You can run ArangoDB and thus Foxx with multiple threads, each having thread-local JavaScript variables. 您可以使用多个线程运行ArangoDB,从而运行Foxx,每个线程都有线程局部JavaScript变量。 If you issue a request to a Foxx route, then the server will pick a random thread to answer the request. 如果您向Foxx路由发出请求,则服务器将选择一个随机线程来回答该请求。 If the JavaScript variable is still empty in this thread, it may need to be populated first (this will be your init call). 如果此变量中的JavaScript变量仍为空,则可能需要首先填充它(这将是您的初始化调用)。 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. 如果已在此线程中填充JavaScript变量,则响应将很快。 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. 在几个请求(至少与--server.threads启动选项中配置的数量)之后,每个线程中的JavaScript变量应该已经初始化,响应时间应该相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM