简体   繁体   English

找出数据库问题

[英]Figure out database problems

At the beginning I would like to say that I am not expert in this domain and It is problematic to describe all nuances. 首先,我想说我不是这个领域的专家,描述所有细微差别是有问题的。 I work on Rails application which uses Mysql database. 我在使用Mysql数据库的Rails应用程序上工作。 Our DB has grown and now we have seriously problems with performance. 我们的数据库已经发展壮大,现在我们在性能方面存在严重问题。 In our app we have two features (for example sync with mobile) which process much data and It causes our database hang. 在我们的应用程序中,我们具有两个功能(例如与移动设备同步),这些功能处理大量数据并导致数据库挂起。 We use newrelic to monitoring which confirmed that we have problems with those two parts of app. 我们使用newrelic进行监视,这确认我们在应用程序的这两部分中存在问题。 My main question is how to profile my app to figure out which actions make the biggest problem? 我的主要问题是如何分析我的应用程序,以找出哪些问题是最大的问题? Which tools I can use? 我可以使用哪些工具? Do you have any tips what I can do/configure DB to improve performance? 您有什么技巧可以改善数据库性能吗? What action I should do to find out where the problem is (next small step)? 我应该采取什么措施找出问题所在(下一个小步骤)? I know that those question are very general but I am junior in this domain and new in rails. 我知道这些问题很笼统,但是我在这个领域比较初级,并且刚接触过Rails。 I believe that more question will appear after your answers ;) 我相信您的答案之后还会出现更多问题;)

Firstly what is the size of db, like how many tables and avg no of rows per table. 首先,db的大小是多少,例如多少个表和每个表的平均行数。 With the basic details available in your question, here are few steps you can look upon. 有了问题中可用的基本详细信息,您可以查看以下几个步骤。

Regarding data sync with mobile. 关于与手机的数据同步。 First step should be avoid heavy processing on the fly rather use background jobs to process the data and store in tables what actually needs to be sent to mobile . 第一步应避免进行繁琐的处理,而应使用后台作业来处理数据并将实际需要存储的内容存储到表中。 So in that case you will avoid multiple queries, rather 1-2 queries should fetch the entire data with minimum processsing. 因此,在这种情况下,您将避免使用多个查询,而应以最少的处理来取1-2个查询来获取整个数据。

I'm sure you must have applied indexing and active model relationship has been properly managed. 我确定您必须已应用索引并已正确管理活动模型关系。 It would actually help if you can post some models and basic relationship between them . 如果您可以发布一些模型以及它们之间的基本关系,则实际上会有所帮助。 Also explan in brief how the sync is being done and apis being handled. 还简要说明同步是如何完成的以及如何处理api。

Use benchmarking to figure the time to fetch data and keep a watch on the logs when processing data. 使用基准测试来计算获取数据的时间,并在处理数据时留意日志。 There are some better benchmarking tooks available. 有一些更好的基准测试可用。

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

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