this post was submitted on 31 Dec 2025
18 points (87.5% liked)

Python

7686 readers
5 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
top 8 comments
sorted by: hot top controversial new old
[–] rimu@piefed.social 4 points 3 weeks ago (1 children)

Wow, very interesting to see Sync doing so well in comparison!

But I thought a lot of the advantage of async is it's ability to handle many concurrent requests? What happens if you run the same tests but this time with 100 requests in parallel?

[–] hackeryarn@lemmy.world 1 points 3 weeks ago (1 children)

This is running with concurrent requests. 64 workers firing request to be exact.

[–] rimu@piefed.social 1 points 3 weeks ago

That sounds like plenty. Cool!

[–] sherbang@chaos.social 1 points 3 weeks ago (2 children)

@hackeryarn It's not clear from this writeup how SQLAlchemy is set up. If you're using a sync postgres driver then you're doing async-to-sync in your code and not testing what you think you're testing.

A test of different async SQLAlchemy configurations would be helpful next to this. Including testing that the SQLAlchemy setup is async all the way through.

[–] logging_strict@programming.dev 2 points 3 weeks ago

I live and breathe this stuff

SQLAlchemy AsyncSession calls greenlet_spawn which wraps a Session sync method. For async dialect+driver, the sqlalchemy dbapi driver will make async connections.

Hey lets make an async call. You mean rewrite the exact code except with dispersed await sprinkled about? Fuck that! Once is enough. Instead wrap the sync call in a greenlet_spawn. And then return to the gulag of static type checking hell forever.

So is it async all the way thru? No. It's async enough™

[–] hackeryarn@lemmy.world 2 points 3 weeks ago

It is using the async driver. I am using FastAPI’s thin wrapper around SQLAlchemy which also does some slight tuning for it to work better with FastAPI in an async mode.

[–] loweffortname@lemmy.blahaj.zone 0 points 3 weeks ago (1 children)

It wasn't clear whether they have a connection proxy in front of the postgres instance. PosrgreSQL connections are expensive, so something like pg_bouncer could also make a big difference here.

(I realize the point was to test python web servers, but it would have been an interesting additional metric.)

[–] hackeryarn@lemmy.world 2 points 3 weeks ago

No connection proxy in this case. The pooled sync test uses client side pooling which shows better performance. Using a proxy would have the same effect, just moves the pooling to server side.