Skip to content

Isolate and remove performance issues (should be no blocking async/await in ctx.do) #32

@nathanclevenger

Description

@nathanclevenger

I noticed many of our services had slowed WAY down vs normal:

{
  "target": "https://api.cf",
  "first": 219,
  "min": 153,
  "p25": 192,
  "med": 205,
  "avg": 205,
  "p75": 219,
  "max": 231
}

My hypothesis was that something in ctx.do was slowing it down, so I made a test in api.cf:

router.all('*', async (req, env) => {
  const { searchParams } = new URL(req.url)
  if (!searchParams.has('test')) {
    const { user } = await env.CTX.fetch(req).then(res => res.json())
    req.user = user
  }
})

and that increased performance by 2000% ... so we need to isolate and resolve whatever is introducing slowness. We should make sure we aren't doing anything async/await to block the thread ... ctx.do should be instant ... my initial suspicion is that this is related to the Analytics Engine stuff we added on Friday.

{
  "target": "https://api.cf?test",
  "first": 13,
  "min": 6,
  "p25": 7,
  "med": 8,
  "avg": 8.4,
  "p75": 10,
  "max": 13
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions