Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
---
title: Deploy Django on Google Cloud C4A (Arm-based Axion VMs)

draft: true
cascade:
draft: true

minutes_to_complete: 30

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.
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.

learning_objectives:
- Provision an Arm-based SUSE SLES virtual machine on Google Cloud (C4A with Axion processors)
- Provision an Arm-based SUSE Linux Enterprise Server (SLES) virtual machine on Google Cloud (C4A with Axion processors)
- Install Django on a SUSE Arm64 (C4A) instance
- Verify Django functionality by running the development server and accessing the default welcome page on the Arm64 VM
- Measure Django application performance by benchmarking request handling throughput and latency using the official ApacheBench (ab) tool with Gunicorn on Arm64 (Aarch64)
- Measure Django application performance by benchmarking request handling throughput and latency using the official ApacheBench (ab) tool with Gunicorn on Arm64 (aarch64)

prerequisites:
- A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
---
title: Getting started with Django on Google Axion C4A (Arm Neoverse-V2)
title: Get started with Django on Google Axion C4A (Arm Neoverse-V2)

weight: 2

layout: "learningpathall"
---

## Google Axion C4A Arm instances in Google Cloud
## Explore Axion C4A Arm instances in Google Cloud

Google Axion C4A is a family of Arm-based virtual machines built on Google’s custom Axion CPU, which is based on Arm Neoverse-V2 cores. Designed for high-performance and energy-efficient computing, these virtual machines offer strong performance for modern cloud workloads such as CI/CD pipelines, microservices, media processing, and general-purpose applications.

The C4A series provides a cost-effective alternative to x86 virtual machines while leveraging the scalability and performance benefits of the Arm architecture in Google Cloud.

To learn more about Google Axion, refer to the [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu) blog.
To learn more about Google Axion, see the [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu) blog.

## Django

[Django](https://www.djangoproject.com/) is a high-level, **open-source Python web framework** that encourages **rapid development** and **clean, pragmatic design**. Developed and maintained by the [Django Software Foundation](https://www.djangoproject.com/foundation/), it simplifies web application development by handling much of the boilerplate and providing powerful built-in features.
## Understand Django on Google Axion C4A (Arm Neoverse-V2)

Django follows the **Model–View–Template (MVT)** architectural pattern and includes robust tools for **authentication**, **URL routing**, **form handling**, **ORM (Object Relational Mapping)**, **session management**, and **administration interface** — all out of the box.
Django is a high-level, open-source Python web framework that encourages rapid development and clean, pragmatic design. Developed and maintained by the [Django Software Foundation](https://www.djangoproject.com/foundation/), it simplifies web application development by handling much of the boilerplate and providing powerful built-in features.

Django is known for its focus on **security**, **scalability**, and **maintainability**, making it suitable for everything from small projects to large-scale enterprise applications. It helps developers build secure, high-performance web applications quickly without reinventing common components.
Django follows the Model–View–Template (MVT) architectural pattern and includes robust tools for authentication, URL routing, form handling, ORM (Object Relational Mapping), session management, and administration interface - all out of the box.

Django is known for its focus on security, scalability, and maintainability, making it suitable for everything from small projects to large-scale enterprise applications. It helps developers build secure, high-performance web applications quickly without reinventing common components.

Common use cases include web applications, content management systems, APIs, e-commerce platforms, and data-driven dashboards. It integrates seamlessly with popular databases like PostgreSQL, MySQL, SQLite, and Oracle.

To learn more, visit the [Django website](https://www.djangoproject.com/) and explore the [Django documentation](https://docs.djangoproject.com/en/stable/).

## Summary and what's next

You now understand the capabilities of Google Axion C4A Arm-based VMs and why Django is an excellent choice for building web applications on Arm infrastructure. The combination provides a cost-effective, high-performance platform for deploying Python web applications at scale.

In the next sections, you'll provision your own Arm-based VM on Google Cloud, install Django, and benchmark your application's performance. You're ready to start building!

Common use cases include **web applications**, **content management systems**, **APIs**, **e-commerce platforms**, and **data-driven dashboards**. It integrates seamlessly with popular databases like **PostgreSQL**, **MySQL**, **SQLite**, and **Oracle**.

To learn more, visit the [official Django website](https://www.djangoproject.com/) and explore the [Django documentation](https://docs.djangoproject.com/en/stable/).
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
---
title: Django Baseline Testing on Google Axion C4A Arm Virtual Machine
title: Verify Django installation and run the development server
weight: 6

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Django Baseline Testing on GCP SUSE VMs
This baseline testing guide verifies that your **Django installation**, **web server**, and **basic application routing** are functioning correctly on a **Google Cloud SUSE Linux Arm64 (Axion C4A)** virtual machine.
You will first run the Django development server and access it from your browser, then create a simple Django app to ensure routing works.
## Verify Django is working on your Arm-based VM

### Baseline 1 — View Django Welcome Page
This test confirms that Django is installed correctly and the server runs successfully.
In this section, you'll confirm that Django is installed correctly and can serve web requests on your Google Cloud C4A VM. You'll create a Django project, run the development server, and access it from your browser. This hands-on verification ensures your environment is ready for development and testing.

By the end of this section, you'll have:
- Created a Django project with proper directory structure
- Configured Django to accept requests from your VM's external IP
- Run the development server and accessed it from your browser
- Built a simple Django app with custom routing and views
- Verified that Django can handle HTTP requests and render responses

Let's get started!

## Create and test a basic Django project

#### Create a new Django project
Run the following command to create a new Django project named `myproject`:

```console
Expand All @@ -32,33 +39,30 @@ myproject/
├── asgi.py
└── wsgi.py
```
- `manage.py` is Django’s command-line utility for project management (running server, migrations, etc.).
- The inner `myproject/` folder contains the core configuration files that define your project’s settings and URLs.-

#### Run initial migrations
Migrations prepare your project’s database by creating the required tables for Django’s internal apps (admin, authentication, etc.):
The `manage.py` file is Django's command-line utility for project management. The inner `myproject/` folder contains your project's core settings and URL configuration.

## Run initial database migrations

Set up your project's database by running migrations, which create the required tables for Django's built-in apps:

```console
python3 manage.py migrate
```

You should get output showing the Running Migrations (all of which should be "OK").
The output shows all migrations applied successfully (marked "OK").

#### Start the Django development server
Before starting the Django development server, you must configure your ALLOWED_HOSTS setting to allow access from your VM’s external IP.
This ensures that Django accepts HTTP requests from outside the localhost (e.g., when testing in a browser or from another machine).
## Configure ALLOWED_HOSTS for external access

**ALLOWED_HOSTS:** is a security setting in Django that defines which host/domain names your Django site can serve.
Before starting the Django development server, you must configure your `ALLOWED_HOSTS` setting to allow access from your VM's external IP. This ensures that Django accepts HTTP requests from outside localhost (for example, when testing in a browser from another machine).

- Navigate to Your Project Settings
Move into your Django project directory where the settings.py file is located.
Navigate to your project settings directory:

```console
cd ~/myproject/myproject/
```
```console
cd ~/myproject/myproject/
```

- Open settings.py File
Use any text editor (like vi or nano) to open the file ("edit" is used as an example below).
Open `settings.py` using a text editor:

```console
edit myproject/settings.py
Expand All @@ -67,60 +71,66 @@ This ensures that Django accepts HTTP requests from outside the localhost (e.g.,
- Locate the `ALLOWED_HOSTS` Line
Inside the file, find the following line:

```python
ALLOWED_HOSTS = []
```
This setting defines which host/domain names Django will serve.
```python
ALLOWED_HOSTS = []
```

Update it to allow your VM's external IP address:

- Allow All Hosts (for Testing Only)
To make your Django app accessible from your VM’s external IP address, update it to:
```python
ALLOWED_HOSTS = ['*']
```
{{% notice Note %}}
Allowing all hosts `('*')` is suitable **only for development or testing**.
For production, replace `'*'` with specific domain names or IPs, such as your public IP address for your VM that you recorded earlier:
For development and testing only, you can use `ALLOWED_HOSTS = ['*']` to allow all hosts. However, for production deployments, always specify explicit domain names or IP addresses such as `ALLOWED_HOSTS = ['your-external-ip', 'your-domain.com']`.
{{% /notice %}}

```python
ALLOWED_HOSTS = ['your-external-ip', 'your-domain.com']
```

**Now start the Django development server:**
Now that you've configured `ALLOWED_HOSTS`, start the development server:

We can now start the Django development server since we have exposed TCP/8000 in our VM via firewall rules:
```console
python3 manage.py runserver 0.0.0.0:8000
```

#### View in browser
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:
This starts the Django development server on port 8000, listening on all network interfaces.

```console
## Access Django in your browser

Open a web browser on your local machine and navigate to:

```
http://<YOUR_VM_EXTERNAL_IP>:8000
```
- Replace `<YOUR_VM_EXTERNAL_IP>` with the public IP of your GCP VM.

If everything is set up correctly, you should see the default Django welcome page (“The install worked successfully!”). It looks like this:
Replace `<YOUR_VM_EXTERNAL_IP>` with the public IP address of your GCP VM.

You should see the Django welcome page with the message "The install worked successfully!":

![Screenshot of the Django welcome page displayed in a web browser. The page features a large heading stating The install worked successfully followed by a subheading congratulating the user on successfully installing Django. Below are instructions for the next steps, including editing the settings file and reading the Django documentation. The page has a clean white background with blue highlights. alt-text#center](images/django-welcome-page.png "Django welcome page")

![Django welcome page alt-text#center](images/django-welcome-page.png "Figure 1: Django web page")
## Build a simple Django app with custom routing

### Baseline 2 — Create a Simple Django App
This test ensures Django’s application routing and view rendering work as expected.
This section demonstrates that Django's application routing and view rendering work correctly by creating a simple app with a custom view.

#### Stop the server
Press `Ctrl + C` to stop the Django server if running.
## Stop the server

Press **Ctrl + C** in your terminal to stop the Django development server.

## Create a new Django app

#### Create a new app
Within your Django project directory, create a new app named `hello`:

```console
python3 manage.py startapp hello
```

**This creates the following directory:**
This generates the following directory structure with files for views, models, configuration, and more:

```markdown
```output
hello/
├── admin.py
├── apps.py
Expand All @@ -130,19 +140,22 @@ hello/
└── urls.py
```

#### Create a simple view
Edit `hello/views.py`. Replace your existing file with this:
## Define a view function

Edit `hello/views.py` and replace the entire file with:

```python
from django.http import HttpResponse

def home(request):
return HttpResponse("<h1>Hello, Django on GCP SUSE ARM64!</h1>")
return HttpResponse("<h1>Hello, Django on Arm!</h1>")
```
This defines a simple view function that sends a basic HTML message as the HTTP response.

#### Create app URL configuration
Create a new file `hello/urls.py` and add:
This simple view function returns a basic HTML message as an HTTP response.

## Create URL configuration for your app

Create a new file `hello/urls.py`:

```python
from django.urls import path
Expand All @@ -152,10 +165,12 @@ urlpatterns = [
path('', views.home, name='home'),
]
```
This maps the root URL `(/)`of your app to the `home()` view function.

#### Link the app to the main project
Replace your default `myproject/urls.py` file with this version.
This maps the root URL path to your `home()` view function.

## Include the app in your project's main URLs

Edit `myproject/urls.py` to include the `hello` app's URLs:

```python
"""myproject URL Configuration
Expand All @@ -182,11 +197,12 @@ urlpatterns = [
path('', include('hello.urls')),
]
```
This tells Django to delegate routing for the root path (`''`) to the `hello` app’s URLs.

#### Add the app to settings
This makes Django aware of your new app so it can load its configuration and routes.
Edit `myproject/settings.py` → add `'hello'` to INSTALLED_APPS:
This tells Django to route the root path to your `hello` app.

## Register the app in Django settings

Django needs to know about your new app. Edit `myproject/settings.py` and add `'hello'` to the `INSTALLED_APPS` list:

```python
INSTALLED_APPS = [
Expand All @@ -199,18 +215,27 @@ INSTALLED_APPS = [
'hello',
]
```
#### Run the server again

## Start the server again

Restart the Django development server:

```console
python3 manage.py runserver 0.0.0.0:8000
```

#### Test your app
Open in browser:
## Test your custom app

Open your browser and navigate to:

```console
http://<YOUR_VM_IP>:8000
```
You should see the Django app. It looks like this:
http://<YOUR_VM_EXTERNAL_IP>:8000
```

You should now see your custom message displayed:

![Screenshot of a web browser displaying a Django app with a large heading that reads Hello, Django on Arm centered on a clean white background. The page contains no additional content or navigation, creating a straightforward and welcoming tone. alt-text#center](images/django-app.png "Django custom app")

## Summary and what's next

![Django App alt-text#center](images/django-app.png "Figure 2: Django App")
You've successfully verified that Django is installed and working on your Arm-based VM. Your application can serve web requests, handle routing, and render custom views. Great job, you're ready to benchmark your Django application!
Loading