Skip to content

Commit 5bb1d6c

Browse files
final updates for the tech review
1 parent e367b85 commit 5bb1d6c

4 files changed

Lines changed: 39 additions & 22 deletions

File tree

content/learning-paths/servers-and-cloud-computing/django-on-gcp/benchmarking.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ Use ApacheBench to test your Django server with simulated traffic:
5757
```console
5858
ab -n 5000 -c 100 http://<external_IP_of_the_GKE_service>/healthz/
5959
```
60-
This sends 5000 requests using 100 concurrent connections to your Django REST endpoint exposed through the GKE LoadBalancer.
60+
This sends 5000 requests using 100 concurrent connections to your Django REST endpoint exposed through the GKE LoadBalancer. After a few minutes, press "CTRL-C" to stop the benchmark and display results similar to:
6161

6262
```output
63-
This is ApacheBench, Version 2.3
64-
Benchmarking 34.132.110.81 (be patient)
65-
6663
Server Software: gunicorn
6764
Server Hostname: 34.132.110.81
6865
Server Port: 80
@@ -99,16 +96,6 @@ Percentage of the requests served within a certain time (ms)
9996
99% 28
10097
100% 34 (longest request)
10198
```
102-
103-
## Stop the Gunicorn server
104-
105-
After reviewing the benchmark results, stop the Gunicorn server running in the background:
106-
107-
```bash
108-
fg
109-
```
110-
This brings the background Gunicorn process to the foreground. Then press `Ctrl+C` to stop it.
111-
11299
## Interpret your benchmark results
113100

114101
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:

content/learning-paths/servers-and-cloud-computing/django-on-gcp/containerization-and-deploy.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You will validate that the workload runs **natively on Arm** and is **publicly a
1313
### Create Docker Image
1414
This step packages your Django API and all its dependencies into a **portable container image** that can run on any Axion Arm64 node.
1515

16-
`requirements.txt`
16+
Create a file called: `requirements.txt` and insert the following:
1717

1818
```text
1919
django
@@ -23,7 +23,7 @@ django-redis
2323
gunicorn
2424
```
2525

26-
`Dockerfile`
26+
Create a file called `Dockerfile` and insert the following:
2727

2828
```dockerfile
2929
FROM python:3.11-slim
@@ -32,23 +32,40 @@ COPY . .
3232
RUN pip install --no-cache-dir -r requirements.txt
3333
CMD ["gunicorn","django_api.wsgi:application","--bind","0.0.0.0:8000","--workers","3"]
3434
```
35+
3536
You now have a container blueprint that can run Django in production using Gunicorn on Arm64.
3637

3738
### Build and Push
38-
This builds the image on an Arm machine and pushes it to Artifact Registry, ensuring Kubernetes pulls an Arm-native image instead of x86.
39+
This builds the image on an Arm machine and pushes it to Artifact Registry, ensuring Kubernetes pulls an Arm-native image:
40+
41+
(Please replace PROJECT_ID with your current project)
42+
43+
Build the docker image first:
3944

4045
```console
4146
docker build -t us-central1-docker.pkg.dev/PROJECT_ID/django-arm/api:1.0 .
47+
```
48+
49+
Then, push the built image:
50+
51+
```console
4252
docker push us-central1-docker.pkg.dev/PROJECT_ID/django-arm/api:1.0
4353
```
54+
4455
Your Django API is now stored in Google’s private container registry and ready for GKE.
4556

4657
### Deploy to GKE
4758
Kubernetes Deployments define how many containers run and where. The nodeSelector forces pods onto Axion ARM64 nodes.
4859

49-
create `/k8sdeployment.yaml` file
60+
First, make a directory:
5061

51-
```pyhton
62+
```console
63+
mkdir ./k8s
64+
```
65+
66+
Next, let's create `k8s/deployment.yaml` file with the following contents (replace PROJECT_ID with your current project):
67+
68+
```python
5269
apiVersion: apps/v1
5370
kind: Deployment
5471
metadata:
@@ -130,14 +147,18 @@ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
130147
django-api LoadBalancer 34.118.226.245 34.45.23.92 80:31700/TCP 3h57m
131148
```
132149

133-
Validate public access
150+
Please wait until the EXTERNAL-IP field gets populated! It will be needed in the next step.
151+
152+
### Validate public access
134153

135-
Open in browser:
154+
Open the following URL in browser:
136155

137156
```bash
138157
http://<EXTERNAL-IP>/healthz/
139158
```
140159

160+
You should see output similar to the following:
161+
141162
![ Django health check alt-text#center](images/django_framework.png "Django Validation")
142163

143164
Your Arm-based Django API is live on the internet.

content/learning-paths/servers-and-cloud-computing/django-on-gcp/django_application.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ DATABASES = {
6969
}
7070
```
7171

72+
Edit the above addition and set "CLOUDSQL_IP" to the actual IP address that you saved from earlier.
73+
7274
Additionally, add the CACHES configuration per below to the same file and save:
7375

7476
```python
@@ -80,6 +82,8 @@ CACHES = {
8082
}
8183
```
8284

85+
Edit the above edition and set REDIS_IP to the actual IP address that you saved earlier.
86+
8387
Your application is now wired to a real database and cache, making it production-grade.
8488

8589
### Migrate Database
@@ -122,6 +126,11 @@ Before containerizing or deploying, you validate that everything works end-to-en
122126

123127
```console
124128
python manage.py runserver 0.0.0.0:8000
129+
```
130+
131+
In a separate SSH session, type:
132+
133+
```console
125134
curl http://127.0.0.1:8000/healthz/
126135
```
127136
**You must see:**

content/learning-paths/servers-and-cloud-computing/django-on-gcp/overview-and-infrastructure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Performance is validated using **throughput** and **p95 latency**, allowing you
2020

2121
### Target Architecture
2222

23-
```text
23+
```output
2424
Client
2525
|
2626
| HTTP (LoadBalancer)

0 commit comments

Comments
 (0)