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
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
1
---
2
2
title: Deploy Django on Google Cloud C4A (Arm-based Axion VMs)
3
3
4
+
draft: true
5
+
cascade:
6
+
draft: true
7
+
4
8
minutes_to_complete: 30
5
9
6
10
who_is_this_for: This learning path is intended for software developers deploying and optimizing Django-based web applications on Linux/Arm64 environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
By default, Google Cloud VMs block external traffic on custom ports like 8000. You must open this port to access Django from your browser.
97
-
98
89
**Now start the Django development server:**
99
90
91
+
We can now start the Django development server since we have exposed TCP/8000 in our VM via firewall rules:
100
92
```console
101
-
python manage.py runserver 0.0.0.0:8000
93
+
python3 manage.py runserver 0.0.0.0:8000
102
94
```
103
95
104
96
#### View in browser
105
-
Open a web browser on your local machine (Chrome, Firefox, Edge, etc.) and enter the following URL in the address bar:
97
+
Open a web browser on your local machine (Chrome, Firefox, Edge, etc.) and enter the following URL in the address bar. Please replace "YOUR_VM_EXTERNAL_IP" with the external IP address of your VM that you saved off earlier:
106
98
107
99
```console
108
100
http://<YOUR_VM_EXTERNAL_IP>:8000
@@ -123,7 +115,7 @@ Press `Ctrl + C` to stop the Django server if running.
123
115
Within your Django project directory, create a new app named `hello`:
124
116
125
117
```console
126
-
python manage.py startapp hello
118
+
python3 manage.py startapp hello
127
119
```
128
120
129
121
**This creates the following directory:**
@@ -150,7 +142,7 @@ def home(request):
150
142
This defines a simple view function that sends a basic HTML message as the HTTP response.
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/django-on-gcp/benchmarking.md
+13-50Lines changed: 13 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Django Benchmarking
3
-
weight: 6
3
+
weight: 7
4
4
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
@@ -11,6 +11,9 @@ layout: learningpathall
11
11
This section describes how to benchmark a Django web application deployed with **Gunicorn** using **ApacheBench (ab)** — a lightweight HTTP benchmarking tool.
12
12
You will measure **throughput (requests per second)** and **latency (response time)** to evaluate the performance of your Django app on an Arm-based GCP SUSE VM.
13
13
14
+
### Stop the server
15
+
Press `Ctrl + C` to stop the Django server if running.
16
+
14
17
### Ensure ApacheBench is installed
15
18
**ApacheBench (ab)** is a command-line tool used to benchmark web servers by simulating multiple HTTP requests.
16
19
@@ -27,45 +30,24 @@ This confirms ApacheBench is correctly installed and available system-wide.
27
30
ab -V
28
31
```
29
32
30
-
### Activate Django Virtual Environment
31
-
A virtual environment isolates Python dependencies for your Django project to prevent version conflicts.
32
-
33
-
```console
34
-
cd ~/myproject
35
-
source venv/bin/activate
36
-
```
37
-
When activated, your shell prompt should show (`venv`) — indicating you’re inside the virtual environment.
38
-
39
33
**Ensure Django and Gunicorn are installed:**
40
34
41
35
```console
42
-
pip install django gunicorn
36
+
python3 -m pip install django gunicorn
43
37
```
44
38
-**Django** is the Python web framework you’re benchmarking.
45
39
-**Gunicorn** is a high-performance WSGI HTTP server for deploying Django apps in production-like environments.
46
40
47
-
### Run Django Migrations and Collect Static Files
48
-
Before running the server, initialize the database and prepare static files.
-`--bind 0.0.0.0:8000`: binds to all interfaces on port 8000
68
-
-Replace `myproject.wsgi:application`with your actual Django project name.
50
+
-`myproject.wsgi:application` your Django project name ("myproject" used in this example).
69
51
70
52
{{% notice Note %}}
71
53
Keep this terminal running during the benchmark. If you’re testing remotely, ensure port 8000 is open in your VM firewall settings.
@@ -138,6 +120,10 @@ Percentage of the requests served within a certain time (ms)
138
120
100% 5 (longest request)
139
121
```
140
122
123
+
### Cleanup
124
+
125
+
With the following output (above) seen, you can type "fg" followed by "ctrl-c" to exit the gunicorn server that is running.
126
+
141
127
### Benchmark Metrics Explanation
142
128
143
129
-**Concurrency Level:** Number of requests executed simultaneously during the test.
@@ -151,28 +137,7 @@ Percentage of the requests served within a certain time (ms)
151
137
-**Time per Request (across concurrent):** Mean time per request across all concurrent clients.
152
138
-**Transfer Rate:** Average network data throughput during the benchmark.
153
139
154
-
### Benchmark summary on x86_64
155
-
To compare the benchmark results, the following results were collected by running the same benchmark on a `x86 - c4-standard-4` (4 vCPUs, 15 GB Memory) x86_64 VM in GCP, running SUSE:
156
-
157
-
|**Parameter**|**Description**|**Value**|
158
-
|----------------|------------------|-----------|
159
-
|**Server Software**| Web server used for serving Django | gunicorn |
In this section, you will learn how to create a Firewall Rule within Google Cloud Console. For this learning path, we need to expose TCP port 8000.
12
+
13
+
{{% notice Note %}}
14
+
For support on GCP setup, see the Learning Path [Getting started with Google Cloud Platform](https://learn.arm.com/learning-paths/servers-and-cloud-computing/csp/google/).
15
+
{{% /notice %}}
16
+
17
+
## Create a Firewall Rule in GCP
18
+
19
+
For this learning path, we need to expose TCP port 8000. To accomplish this, we first need to create a firewall rule.
20
+
- Navigate to the [Google Cloud Console](https://console.cloud.google.com/).
21
+
- Go to **VPC Network > Firewall** and press **Create firewall rule**.
22
+
23
+

24
+
25
+
- Next, we create the firewall rule that will expose TCP port 8000 for our learning path.
26
+
- Set the "Name" of the new rule to "allow-tcp-8000"
27
+
- Select your network that you intend to bind to your VM (default is "autoscaling-net" but your organization might have others that you need to use)
28
+
- Direction of traffic should be set to "Ingress"
29
+
- Allow on match should be set to "Allow" and the "Targets" should be set to "Specified target tags".
30
+
- Enter "allow-tcp-8000" to the "Target tags" text field
31
+
- Set the "Source IPv4 ranges" text value to "0.0.0.0/0"
32
+
33
+

34
+
35
+
- Lastly, we select "Specified protocols and ports" under the "Protocols and ports" section
36
+
- Select the "TCP" checkbox
37
+
- Enter "8000" in the "Ports" text field
38
+
- Press "Create"
39
+
40
+

41
+
42
+
Our network firewall rule is now created so we can continue with the VM creation!
In this section, you will learn how to create a Firewall Rule within Google Cloud Console. For this learning path, we need to expose TCP port 8000.
12
+
13
+
{{% notice Note %}}
14
+
For support on GCP setup, see the Learning Path [Getting started with Google Cloud Platform](https://learn.arm.com/learning-paths/servers-and-cloud-computing/csp/google/).
15
+
{{% /notice %}}
16
+
17
+
## Create a Firewall Rule in GCP
18
+
19
+
For this learning path, we need to expose TCP port 8000. To accomplish this, we first need to create a firewall rule.
20
+
- Navigate to the [Google Cloud Console](https://console.cloud.google.com/).
21
+
- Go to **VPC Network > Firewall** and press **Create firewall rule**.
22
+
23
+

24
+
25
+
- Next, we create the firewall rule that will expose TCP port 8000 for our learning path.
26
+
- Set the "Name" of the new rule to "allow-tcp-8000"
27
+
- Select your network that you intend to bind to your VM (default is "autoscaling-net" but your organization might have others that you need to use)
28
+
- Direction of traffic should be set to "Ingress"
29
+
- Allow on match should be set to "Allow" and the "Targets" should be set to "Specified target tags".
30
+
- Enter "allow-tcp-8000" to the "Target tags" text field
31
+
- Set the "Source IPv4 ranges" text value to "0.0.0.0/0"
32
+
33
+

34
+
35
+
- Lastly, we select "Specified protocols and ports" under the "Protocols and ports" section
36
+
- Select the "TCP" checkbox
37
+
- Enter "8091" in the "Ports" text field
38
+
- Press "Create"
39
+
40
+

41
+
42
+
Our network firewall rule is now created so we can continue with the VM creation!
0 commit comments