0

According to the documentation for blocking operations, I use synchronous functions:

import time

from fastapi import FastAPI

app = FastAPI()


@app.get(path='/index')
def index():
    time.sleep(2)
    return 'true'
uvicorn main:app --reload

But on testing, I see that the requests are executed sequentially and not in parallel:

ab -n 2 -c 2 http://127.0.0.1:8000/index

Server Software:        uvicorn
Server Hostname:        127.0.0.1
Server Port:            8000

Document Path:          /index
Document Length:        6 bytes

Concurrency Level:      2
Time taken for tests:   4.021 seconds
Complete requests:      2
Failed requests:        0

Why it happens? Shouldn't they run in parallel?

nosheyakku
  • 196
  • 9

0 Answers0