I am working with Django and want to maximize the ability to handle web requests per second that interact with a db

Gordon Long 0 Reputation points
2024-11-06T17:04:18.05+00:00

I am working with Django and want to maximize the ability to handle web requests per second that interact with a db. How would you recommend setting this up? I am using a postgresql db and can try to spin up more CPUs to have more worker threads, but so far struggling to get the application to work asynchronously (likely because of db requests). I have thus far max'd out at 30 requests/second but hoping to get much higher.

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
975 questions
Azure Startups
Azure Startups
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Startups: Companies that are in their initial stages of business and typically developing a business model and seeking financing.
396 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Laxman Reddy Revuri 410 Reputation points Microsoft Vendor
    2024-11-11T15:41:08.4166667+00:00

    Hi @Gordon Long
    Load Balancing (Horizontal Scaling) on Azure

    Standalone Database Server for Multiple Django Servers

    • Centralized Database:
    • Use a separate, standalone database server accessible by all app instances.
    • Ensure the database can handle connections from multiple servers (use connection pooling). Set up replication (read replicas) to distribute read queries and reduce load on the primary database. Implement caching (e.g., Redis) to offload frequent queries and reduce database load. Azure Database for PostgreSQL/MySQL: Provides automatic backups, scaling, and high availability.  Azure Redis Cache: Integrate Redis for caching queries and storing sessions.  
      If the answer is helpful, please click "Accept Answer" and kindly upvote it.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.