You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/django-on-gcp/_index.md
+24-7Lines changed: 24 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,19 @@ title: Deploy Django on Google Cloud C4A (Arm-based Axion VMs)
3
3
4
4
minutes_to_complete: 30
5
5
6
-
who_is_this_for: This Learning Path is for software developers deploying and optimizing Django-based web applications on Arm64 Linux environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
6
+
who_is_this_for: This Learning Path is designed for DevOps engineers and software developers who want to deploy, operate, and benchmark a production-grade Django REST API on Google Kubernetes Engine (GKE) running on Arm64 Axion processors, integrated with managed Google Cloud data services.
7
7
8
8
learning_objectives:
9
9
- Provision an Arm-based SUSE Linux Enterprise Server (SLES) virtual machine on Google Cloud (C4A with Axion processors)
10
-
- Install Django on a SUSE Arm64 (C4A) instance
11
-
- Verify Django functionality by running the development server and accessing the default welcome page on the Arm64 VM
12
-
- Measure Django application performance by benchmarking request handling throughput and latency using the official ApacheBench (ab) tool with Gunicorn on Arm64 (aarch64)
10
+
- Provision Google Axion (Arm64) compute using GKE node pools
11
+
- Package a Django REST API into an Arm-native Docker container
12
+
- Push container images to Google Artifact Registry
13
+
- Deploy Django on GKE using Kubernetes manifests (Deployment, Service, ConfigMap, Secrets)
14
+
- Integrate Django with Cloud SQL (PostgreSQL) over private IP
15
+
- Integrate Django with Memorystore (Redis) for caching and sessions
16
+
- Expose Django using a Kubernetes LoadBalancer
17
+
- Validate application connectivity to PostgreSQL and Redis
18
+
- Measure throughput and p95 latency using ApacheBench against Gunicorn on Arm
13
19
14
20
prerequisites:
15
21
- A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled
title: Benchmark Django application performance on Arm
3
-
weight: 7
3
+
weight: 10
4
4
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
@@ -19,8 +19,8 @@ ApacheBench (`ab`) is a command-line tool that simulates multiple HTTP requests
19
19
```console
20
20
sudo zypper install -y apache2-utils
21
21
```
22
-
## Verify installation
23
22
23
+
### Verify installation
24
24
This command confirms ApacheBench is correctly installed and available system-wide:
25
25
26
26
```console
@@ -29,161 +29,145 @@ ab -V
29
29
30
30
The output displays the ApacheBench version, confirming successful installation.
31
31
32
-
## Install and configure Gunicorn
32
+
###Install and configure Gunicorn
33
33
34
34
Before benchmarking your Django application, you need to install Gunicorn, a production-grade WSGI HTTP server. Gunicorn provides better performance characteristics than Django's development server and more accurately represents real-world deployment scenarios.
35
35
36
-
Install both Django and Gunicorn using pip:
36
+
### Install both Django and Gunicorn using pip:
37
37
38
38
```console
39
39
python3 -m pip install django gunicorn
40
40
```
41
-
42
41
This command installs two essential packages. Django is the Python web framework you're benchmarking, while Gunicorn serves as a high-performance WSGI HTTP server that handles multiple concurrent requests efficiently. Unlike Django's built-in development server, Gunicorn is designed for production workloads and provides the multi-worker architecture needed for accurate performance testing.
43
42
43
+
### Run Django with Gunicorn
44
+
Start your Django application using Gunicorn (already running inside GKE):
This command starts Gunicorn with four worker processes to handle concurrent requests. Replace `myproject` with your Django project's actual name. The `--bind 0.0.0.0:8000` flag makes the server accessible on port 8000 from any network interface, while the `&` runs the process in the background so you can continue using your terminal.
46
+
Gunicorn is deployed inside your Kubernetes Pods and exposed via a Kubernetes Service and LoadBalancer.
47
+
The benchmark is executed against the **external IP of the GKE service**.
54
48
55
49
{{% notice Note %}}
56
50
Ensure your VM's firewall allows inbound traffic on port 8000. See the firewall setup section if you haven't already configured this.
57
51
{{% /notice %}}
58
52
59
-
## Run the benchmark
53
+
### Run the benchmark
54
+
60
55
Use ApacheBench to test your Django server with simulated traffic:
61
56
62
57
```console
63
-
ab -n 1000 -c 10 http://127.0.0.1:8000/
58
+
ab -n 5000 -c 100 http://<external_IP_of_the_GKE_service>/healthz/
64
59
```
65
-
66
-
This sends 1000 requests using 10 concurrent connections to your local server's root URL. The `-n` flag sets the total number of requests, while `-c` controls how many run simultaneously.
67
-
68
-
The output is similar to:
60
+
This sends 5000 requests using 100 concurrent connections to your Django REST endpoint exposed through the GKE LoadBalancer.
69
61
70
62
```output
71
63
This is ApacheBench, Version 2.3
72
-
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
73
-
Licensed to The Apache Software Foundation, http://www.apache.org/
74
-
75
-
Benchmarking 127.0.0.1 (be patient)
76
-
Completed 100 requests
77
-
Completed 200 requests
78
-
Completed 300 requests
79
-
Completed 400 requests
80
-
Completed 500 requests
81
-
Completed 600 requests
82
-
Completed 700 requests
83
-
Completed 800 requests
84
-
Completed 900 requests
85
-
Completed 1000 requests
86
-
Finished 1000 requests
64
+
Benchmarking 34.132.110.81 (be patient)
87
65
88
66
Server Software: gunicorn
89
-
Server Hostname: 127.0.0.1
90
-
Server Port: 8000
67
+
Server Hostname: 34.132.110.81
68
+
Server Port: 80
91
69
92
-
Document Path: /
93
-
Document Length: 41 bytes
70
+
Document Path: /healthz/
71
+
Document Length: 15 bytes
94
72
95
-
Concurrency Level: 10
96
-
Time taken for tests: 0.104 seconds
97
-
Complete requests: 1000
73
+
Concurrency Level: 100
74
+
Time taken for tests: 0.357 seconds
75
+
Complete requests: 5000
98
76
Failed requests: 0
99
-
Total transferred: 280000 bytes
100
-
HTML transferred: 41000 bytes
101
-
Requests per second: 9651.21 [#/sec] (mean)
102
-
Time per request: 1.036 [ms] (mean)
103
-
Time per request: 0.104 [ms] (mean, across all concurrent requests)
104
-
Transfer rate: 2639.00 [Kbytes/sec] received
77
+
Total transferred: 1650000 bytes
78
+
HTML transferred: 75000 bytes
79
+
Requests per second: 14001.88 [#/sec] (mean)
80
+
Time per request: 7.142 [ms] (mean)
81
+
Time per request: 0.071 [ms] (mean, across all concurrent requests)
82
+
Transfer rate: 4512.32 [Kbytes/sec] received
105
83
106
84
Connection Times (ms)
107
85
min mean[+/-sd] median max
108
-
Connect: 0 0 0.1 0 1
109
-
Processing: 010.31 4
110
-
Waiting: 0 10.31 3
111
-
Total: 010.41 5
86
+
Connect: 0 0 0.2 0 2
87
+
Processing: 164.7632
88
+
Waiting: 0 64.7632
89
+
Total: 174.8634
112
90
113
91
Percentage of the requests served within a certain time (ms)
114
-
50% 1
115
-
66% 1
116
-
75% 1
117
-
80% 1
118
-
90% 1
119
-
95% 2
120
-
98% 2
121
-
99% 3
122
-
100% 5 (longest request)
92
+
50% 6
93
+
66% 9
94
+
75% 10
95
+
80% 11
96
+
90% 11
97
+
95% 11
98
+
98% 16
99
+
99% 28
100
+
100% 34 (longest request)
123
101
```
102
+
124
103
## Stop the Gunicorn server
125
104
126
105
After reviewing the benchmark results, stop the Gunicorn server running in the background:
127
106
128
107
```bash
129
108
fg
130
109
```
131
-
132
110
This brings the background Gunicorn process to the foreground. Then press `Ctrl+C` to stop it.
133
111
134
112
## Interpret your benchmark results
135
113
136
-
The ApacheBench output provides key performance metrics that help you evaluate your Django application's capabilities on Arm. Here's what each metric tells you:
114
+
The ApacheBench output provides key performance metrics that help you evaluate your Django application's capabilities on Google Axion (Arm64) GKE. Here's what each metric tells you:
137
115
### Request handling metrics
138
-
- Concurrency Level: number of simultaneous requests the benchmark sent (10 in this example)
139
-
- Complete Requests: total successful requests processed (1000 in this test)
140
-
- Failed Requests: number of errors or timeouts (0 indicates stable performance)
116
+
- Concurrency Level: number of simultaneous requests the benchmark sent (100 in this test)
117
+
- Complete Requests: total successful requests processed (5000 in this test)
118
+
- Failed Requests: number of errors or timeouts (0, indicating stable production-grade performance)
141
119
142
120
### Performance metrics
143
-
- Requests per Second: how many requests your server handles per second - higher values indicate better throughput
144
-
- Time per Request (mean): average time to complete a single request - lower values mean faster responses
145
-
- Time per Request (across concurrent): average latency when factoring in concurrent processing, this shows how well your app handles parallel requests
121
+
- Requests per Second: how many requests your server handles per second — higher values indicate better throughput (14,001.88 req/sec)
122
+
- Time per Request (mean): average time to complete a single request (7.142 ms)
123
+
- Time per Request (across concurrent): average latency when factoring in concurrent processing (0.071 ms), showing excellent parallel execution on Axion Arm cores
146
124
147
125
### Data transfer metrics
148
-
- Total Transferred: all data sent and received, including HTTP headers
149
-
- HTML Transferred: actual response content size
150
-
- Transfer Rate: network throughput in KB/sec—indicates data handling efficiency
126
+
- Total Transferred: all data sent and received, including HTTP headers (1,650,000 bytes)
127
+
- HTML Transferred: actual response payload size (75,000 bytes)
128
+
- Transfer Rate: network throughput in KB/sec (4512.32 KB/sec), indicating efficient networking through GKE LoadBalancer
129
+
151
130
### Timing breakdown
152
-
- Time Taken for Tests: total benchmark duration
131
+
- Time Taken for Tests: total benchmark duration (0.357 seconds)
153
132
- Connection Times: shows minimum, mean, median, and maximum times for connecting, processing, and waiting
154
133
155
-
These metrics provide a performance baseline for your Django application on Arm. You can use them to compare different configurations, identify bottlenecks, or validate optimizations.
134
+
These metrics establish a real production-grade performance baseline for your Django REST API running on GKE Axion (Arm64) with Gunicorn, Cloud SQL, and Redis.
156
135
157
136
## Benchmark summary
158
137
159
-
The table below summarizes the key performance indicators from the benchmark test. These results demonstrate the capabilities of your Django application running on a Google Cloud C4A Arm-based VM with Gunicorn.
138
+
The table below summarizes the key performance indicators from your real benchmark run on the Axion Arm64 GKE cluster.
160
139
161
-
Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE):
140
+
Results from the run on the `Axion (C4A) Arm64 GKE nodes`:
162
141
163
142
|**Parameter**|**Description**|**Value**|
164
-
|----------------|------------------|-----------|
143
+
|--------------|------------------|-----------|
165
144
|**Server Software**| Web server used for serving Django | gunicorn |
The benchmark results reveal several important characteristics of running Django on Arm-based infrastructure:
167
+
The benchmark results demonstrate the strength of running Django on Google Axion (Arm64) GKE:
184
168
185
-
-Exceptional Throughput: the Arm64 VM efficiently handled nearly 10K requests per second, showcasing excellent concurrency handling.
186
-
- Low Latency: average response time stayed around 1 ms, indicating rapid request processing even under load.
187
-
-High Efficiency: zero failed requests demonstrate stable and reliable performance under benchmark conditions.
188
-
-Optimized Networking: strong data transfer rate highlights Arm64's efficient network I/O capabilities.
189
-
-Ideal for Scalable Apps: the consistent and predictable response times make Arm64 VMs well-suited for high-performance web workloads.
169
+
-Extreme Throughput: The cluster sustained 14,000+ requests per second through a public LoadBalancer → GKE → Gunicorn → Django → Cloud SQL → Redis stack.
170
+
-Ultra-Low p95 Latency: Even at 100 concurrent users, 95% of all requests completed within 11 ms, proving excellent tail-latency control.
171
+
-Production Stability: Zero failed requests confirms the platform is resilient under heavy parallel load.
172
+
-Efficient Networking: Over 4.4 MB/sec of data transfer through the GKE LoadBalancer shows Arm-based networking is highly optimized.
173
+
-Cloud-native Scalability: These results validate that Axion Arm64 nodes are well-suited for high-performance, horizontally scalable REST APIs in production.
0 commit comments