question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance issue while returning a large Object

See original GitHub issue

I have a 1.7MB object to send.

Doing this will cause a TTFB time of 330ms (that’s ok) and a Content download time of 4s in Chrome.

router.get('/heavy', async function heavyRoute(ctx, next) {
  const result = await collectHeavyData()
  ctx.body = result // my 1.7MB object
  console.log('less than 100ms and we are here')
})

The same logic written with .NET cause a TTFB time of 2s (that’s ok, my bad) and a Content download time of 92ms.

The response are the same, the Koa route code execute in less than 100ms, but the client get the complete response really slowly.

Am I missing something?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jonathanongcommented, Nov 21, 2017

try using streams or a more optimized JSON.stringify() module

0reactions
fl0wcommented, Mar 5, 2018

I am going to close this issue. Feel free to re-open if you still believe this to be an issue with Koa.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Returning Large Objects in Functions - c++ - Stack Overflow
The emphasis on a "large object" refers to the fact that repeated copies of the object, unnecessarily, is wasted cycles.
Read more >
Where does the performance penalty from returning larger ...
Looking at the assembly generated by MSVC, it appears that it unrolls the loop when your struct has nothing but your float, while...
Read more >
bad performance and high memory usage when returning ...
I encountered a performance issue when returning a large array o. ... high memory usage when returning large array of nested objects #2605....
Read more >
Pmap extremely slow when function returns large object
I would like to parallelize a function but returning large objects makes pmap extremely slow. using Distributed using SharedArrays ...
Read more >
4. Object Creation - Java Performance Tuning, 2nd Edition ...
This class creates and dereferences a huge number of objects while it parses a stream, and the effect is to slow down processing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found