TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Optimizing for the Speed of Light

40 pointsby elemenoover 5 years ago

7 comments

stormbrewover 5 years ago
&gt; In C#&#x2F;typescript you can no longer use the friendly `await` keyword that makes async calls almost as easy synchronous calls. Ironically, the `await` keyword makes it really easy to force HTTP requests to execute sequentially that could easily execute in parallel. This is what the pit of fail looks like!<p>I&#x27;m not specifically familiar with C# or typescript&#x27;s async keyword implementations, but this.. shouldn&#x27;t be true?<p>If you can&#x27;t launch multiple requests and then gather their results either through aggregating to a single future or by awaiting on them individually (which will mean you will start acting on results somewhere between min(t1,t2,t3,..tn) and max(t1,t2,t3,..tn) time) while all of them proceed just as well as if you had done callbacks, that&#x27;s not a very good implementation of async&#x2F;await...
评论 #21898048 未加载
评论 #21898313 未加载
planck01over 5 years ago
Summary: Many round trips of small api requests can add up a lot of latency. An often used tactic is to bundle requests. Even better is to locally cache data when possible.<p>Is this news for anybody here?
评论 #21899954 未加载
chupa-chupsover 5 years ago
Since the site doesn&#x27;t load currently - which is a bit funny considering the title - archive.is comes to the rescue:<p><a href="http:&#x2F;&#x2F;archive.is&#x2F;8Wj44" rel="nofollow">http:&#x2F;&#x2F;archive.is&#x2F;8Wj44</a>
评论 #21898732 未加载
评论 #21899312 未加载
bgirardover 5 years ago
The article overlooks the end-to-end overhead of HTTP&#x2F;2 which unfortunately makes the trade-offs between batching API calls and bundling JavaScript very complex in practice. For instance in Chrome the overhead of an additional request is still several milliseconds of local CPU time. Which means in practice you&#x27;ll trade off CPU time to benefit warm loads where the cache is populated.<p>I&#x27;m hopeful someday the overhead will be made negligible but until then I&#x27;d suggest profiling the trade-offs.<p>Meanwhile data frameworks like Relay offer incremental flushing with much more flexibility all over a single request.
评论 #21898382 未加载
tyzerdakover 5 years ago
In android tutorials from Google they say we should make as little requests as we can because every request call takes much phone power
HenriNextover 5 years ago
Bundling is not only about performance though.<p>Fetching all resources in a single HTTP request (or all data in a single GraphQL query) avoids a lot of issues and workaround effort caused by non-deterministic completion order of multiple small requests.
markb139over 5 years ago
I think the guy needs to read a bit more physics. Electricity travels at about 2&#x2F;3 the speed of light in copper wires.
评论 #21898163 未加载
评论 #21899614 未加载