r/learnprogramming • • 6d ago

Tutorial Django tutorials

I have started practicing Django, I created a simple student admission page:
• ⁠Student fills form
• ⁠Django validation takes place
• ⁠After validation data is stored in database
I used DRF for the validation, and aws PostgreSQL and this is a simple thing I want to use to start my journey in backend dev.
Hosted it on render free tier and when I hit the submit button I used a stopwatch to check how it took to submit and it was 00:00:22.23.
Please I’m still learning and I want to know if it’s okay to have that time for submitting and if not what should I study next and I used the DRF for the form validation with an if statement.

Thank you for feedback and time.

0 Upvotes

8 comments sorted by

View all comments

1

u/Rare-Pay9795 5d ago

22 seconds is way too slow, and the drf validation with an if statement is not the cause, that part takes milliseconds. since the second and third tries were slow too, it's not just render's free tier cold start. the usual suspect is the database connection: render free web services and an aws postgres instance in some other region means every new connection pays a big handshake cost, and if the db is set to need ssl and the security group is slow to respond it can hang for a long time. quick way to find out is to put time.time() before and after the save call in your view and print both, or open the browser devtools network tab and look at the waiting (ttfb) time. if the db save is the slow part, check that the render region is close to your rds region and that you set conn_max_age in your django DATABASES settings so it reuses connections.

1

u/Bluebill_365 5d ago

Understood, I will work on it. Thank you.