Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
Why asynchronous counterpart of a synchronous method have less throughput?

I have 2 API endpoints which basically performs the same. Loads an item from Database using Ef Core and return it as response. The difference is one is synchronous and other is asynchronous, specifically, the call to Ef Core is synchronous in first method and asynchronous in the second.

I was performing load testing on both endpoints using Bombardier. At first I use only 1 connection with 5000 requests and synchronous method performed well. I thought context switching in asynchronous method might be responsible for this as there is only 1 connection. Then I increased connections to 150 but still synchronous method perform way better and has much more throughput than the asynchronous one as you can see in the image below. First output is of synchronous version and second is of asynchronous version.

I thought more connection there will be the asynchronous method will shine as it won't wait for the existing connection and will take on the other connection. What is here that I'm not understanding? Could anyone explain it to me.

enter image description here

UPDATE

Here is my code and also I re-ran the test, including its result as well.

        [HttpGet("a")]
        public IActionResult Get()
        {
            var invoices = context.Invoices
                .Include(it => it.InvoiceItems)
                .ToList();
            return Ok(invoices);
        }

        [HttpGet("b")]
        public async Task<IActionResult> GetAsync()
        {
            var invoices = await context.Invoices
                .Include(it => it.InvoiceItems)
                .ToListAsync();
            return Ok(invoices);
        }

enter image description here

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda