Reader small image

You're reading from  Hands-On Microservices with Django

Product typeBook
Published inMay 2024
PublisherPackt
ISBN-139781835468524
Edition1st Edition
Right arrow
Author (1)
Tieme Woldman
Tieme Woldman
author image
Tieme Woldman

Tieme Woldman works as a freelance Python developer and technical writer. As a Python developer, he builds web and data engineering applications with Django and Python data transformation packages such as pandas. As a technical writer, he has written software and user documentation for software companies such as Instruqt, Noldus Information Technology, and Rulecube. Tieme lives in the Netherlands, has a bachelor's degree in computer science, and holds several (technical) writing certifications.
Read more about Tieme Woldman

Right arrow

Setting Up the Development and Runtime Environment

We’ve finished the introduction of Django microservices and are now ready to set up our development and runtime environment so we can start building microservices.

In this chapter, you’ll learn what applications and Python packages are needed to build Django microservices and how you install them. Furthermore, you’ll be introduced to the sample microservices application you will develop throughout the following chapters.

By the end of this chapter, you’ll know how to set up your toolset for developing Django microservices, and you’ll be ready to start building. In addition, you’ll have a clear picture of the microservices application that you’ll build step by step over the course of this book.

Hence, this chapter addresses the following topics:

  • Setting up the development environment
  • Setting up the runtime environment
  • Analyzing the sample microservices application...

Technical requirements

This chapter’s remainder describes the applications and Python packages needed to develop and run Django microservices. As a start, you need a workstation running Linux, Mac OS, or Windows 10/11.

Since Celery doesn’t run on Windows, you may wonder why Windows 10/11 is still an option. This is because Windows Subsystem for Linux (WSL) allows you to run virtual Linux distributions on Windows 10/11, such as the Ubuntu distribution.

Furthermore, we’ll use Visual Studio Code (VS Code) as our code editor because it’s available for Linux, Mac OS, and Windows. And because it integrates well with WSL and MongoDB, the database that we’ll be using.

Altogether, you’ll need the following:

  • A (virtual) workstation running one of these operating systems:
    • Linux, such as Ubuntu 22.04 LTS
    • Mac OS
    • Windows 10 version 2004 or newer
    • Windows 11
  • Python version 3.8 or newer
  • VS Code

This chapter doesn’t contain...

Setting up the development environment

As developers, we need a toolbook to work with and get started. So, we’ll begin with our development environment. Because Linux also runs on Windows through WSL and Linux shell commands overlap with Mac OS commands, this book utilizes Linux as a development and runtime platform. So we catch three birds with one stone.

If you’re on Windows, you first need to install WSL and Ubuntu as described in the subsection, Extra setup for Windows developers. If you’re on Linux or Mac OS, you can skip this subsection and jump to the Installing the required Python packages subsection.

Extra setup for Windows developers

If you’re on Windows 10 or 11, you must activate WSL and install an Ubuntu instance to follow along. You also need to install Windows Terminal and integrate WSL with VS Code.

Setting up WSL and Ubuntu is easy:

  1. Open your BIOS settings and check if virtualization is enabled. If needed, enable virtualization...

Setting up the runtime environment

For our runtime environment, we’ll set up the following software:

  • RabbitMQ: to act as a message broker.
  • Redis: to act as a message-handling vehicle for Celery and to provide caching.
  • MongoDB: to store our data.
  • Docker: to containerize our software and microservices.

MongoDB is the database that our microservices application will use. We cloud use PostgreSQL, MySQL, or another database as well, but MongoDB can run entirely in the cloud, which aligns nicely with our principle of building cloud-native microservices.

Because we’ll run RabbitMQ and Redis as Docker containers, we’ll start with installing Docker Desktop.

Installing Docker Desktop

Docker Desktop allows you to containerize applications on your workstation, and the installation depends on your platform:

Analyzing the sample microservices application

Throughout the rest of this book, we’ll explore developing Django microservices in detail and put that into practice by creating a sample microservices application.

Regarding that sample application, the Product Owner of the Subscription Management team of a computer magazine publisher asked us to develop a new web app for registering subscriptions.

The present app registers all new subscriptions without checking if a newly entered address already exists in the address list. This causes the same addresses to appear multiple times in the list with slightly different spelling. For example, the address East River Street 14 occurs in these variants:

  • East River Street 14
  • East river street 14
  • East River str. 14
  • East river str. 14
  • Eest River street 14
  • East Rover street 14

The first four variants differ in capitalization and abbreviation. The last two variants are due to typos, but the current app...

Summary

This chapter taught us how to set up our development and runtime environment for building Django microservices. We paid special attention to Windows developers, who need WSL on their workstations to develop with the Ubuntu Linux distribution.

When the Windows developers caught up, we installed the necessary Python packages and additional software like RabbitMQ and Redis for message brokering. Finally, we analyzed the sample microservices application, which we’ll develop throughout this book.

This closes Part 1, Introducing Microservices and Getting Started, and sets us up for the next chapter, where we lay the data processing foundation for Django microservices with a MongoDB cloud-native database.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Microservices with Django
Published in: May 2024Publisher: PacktISBN-13: 9781835468524
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Tieme Woldman

Tieme Woldman works as a freelance Python developer and technical writer. As a Python developer, he builds web and data engineering applications with Django and Python data transformation packages such as pandas. As a technical writer, he has written software and user documentation for software companies such as Instruqt, Noldus Information Technology, and Rulecube. Tieme lives in the Netherlands, has a bachelor's degree in computer science, and holds several (technical) writing certifications.
Read more about Tieme Woldman

Platform

Instructions/URL

Linux...