如何减少等待时间

如何减少等待时间

本文介绍了如何减少等待时间(ttfb)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询,涉及根据创建时间从表中以排序的顺序获取用户列表.我从chrome开发人员工具中获得了以下时序图.

I have a query which involves getting a list of user from a table in sorted order based on at what time it was created. I got the following timing diagram from the chrome developer tools.

您会看到TTFB(至第一个字节的时间)过高.
我不确定是否是因为SQL排序.如果那是原因,那我该如何减少时间呢?
还是因为TTFB.我看到了一些博客,其中说TTFB应该更短( 1秒.是因为我的查询还是其他原因?
我不确定如何减少此时间.
我正在使用角度.我应该使用angular对表进行排序而不是对SQL进行排序吗? (许多帖子说这不应该成为问题)
我想知道的是如何减少TTFB.伙计们!我实际上是新来的.这是我的团队成员给我的任务.我不确定如何减少TTFB时间.我看到了很多帖子,但无法正确理解.什么是TTFB.是服务器花费的时间吗?

You can see that TTFB (time to first byte) is too high.
I am not sure whether it is because of the SQL sort. If that is the reason then how can I reduce this time?
Or is it because of the TTFB. I saw blogs which says that TTFB should be less (< 1sec). But for me it shows >1 sec. Is it because of my query or something else?
I am not sure how can I reduce this time.
I am using angular. Should I use angular to sort the table instead of SQL sort? (many posts say that shouldn't be the issue)
What I want to know is how can I reduce TTFB. Guys! I am actually new to this. It is the task given to me by my team members. I am not sure how can I reduce TTFB time. I saw many posts, but not able to understand properly. What is TTFB. Is it the time taken by the server?

推荐答案

TTFB不是响应正文(即有用数据,例如json,xml等)的第一个字节的时间,而是从服务器接收到响应的第一个字节的时间.该字节是响应头的开头.

The TTFB is not the time to first byte of the body of the response (i.e., the useful data, such as: json, xml, etc.), but rather the time to first byte of the response received from the server. This byte is the start of the response headers.

例如,如果服务器在进行艰苦的工作之前先发送标头(例如繁重的SQL),您将获得一个非常低的TTFB,但这不是"true".

For example, if the server sends the headers before doing the hard work (like heavy SQL), you will get a very low TTFB, but it isn't "true".

在您的情况下,TTFB表示您在服务器上处理数据所花费的时间.

In your case, TTFB represents the time you spend processing data on the server.

要减少TTFB,您需要更快地完成服务器端的工作.

这篇关于如何减少等待时间(ttfb)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 06:54