We may earn an affiliate commission when you visit our partners.
Course image
Trevor Sawler

For a long time, web applications were usually a single application that handled everything—in other words, a monolithic application. This monolith handled user authentication, logging, sending email, and everything else. While this is still a popular (and useful) approach, today, many larger scale applications tend to break things up into microservices. Today, most large organizations are focused on building web applications using this approach, and with good reason.

Read more

For a long time, web applications were usually a single application that handled everything—in other words, a monolithic application. This monolith handled user authentication, logging, sending email, and everything else. While this is still a popular (and useful) approach, today, many larger scale applications tend to break things up into microservices. Today, most large organizations are focused on building web applications using this approach, and with good reason.

Microservices, also known as the microservice architecture, are an architectural style which structures an application as a loosely coupled collection of smaller applications. The microservice architecture allows for the rapid and reliable delivery of large, complex applications. Some of the most common features for a microservice are:

  • it is maintainable and testable;

  • it is loosely coupled with other parts of the application;

  • it  can deployed by itself;

  • it is organized around business capabilities;

  • it is often owned by a small team.

In this course, we'll develop a number of small, self-contained, loosely coupled microservices that will will communicate with one another and a simple front-end application with a REST API, with RPC, over gRPC, and by sending and consuming messages using AMQP, the Advanced Message Queuing Protocol. The microservices we build will include the following functionality:

  • A Front End service, that just displays web pages;

  • An Authentication service, with a Postgres database;

  • A Logging service, with a MongoDB database;

  • A Listener service, which receives messages from RabbitMQ and acts upon them;

  • A Broker service, which is an optional single point of entry into the microservice cluster;

  • A Mail service, which takes a JSON payload, converts into a formatted email, and send it out.

All of these services will be written in Go, commonly referred to as Golang, a language which is particularly well suited to building distributed web applications.

We'll also learn how to deploy our distributed application to a Docker Swarm and Kubernetes, and how to scale up and down, as necessary, and to update individual microservices with little or no downtime.

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • Learn what microservices are and when to use them
  • How to develop loosely coupled, single purpose applications which work together as a distributed application
  • How to communicate between services using json, remote procedure calls, and grpc
  • How to push events to microservices using the advanced message queuing protocol (amqp) using rabbitmq
  • How to deploy your distributed application to docker swarm
  • How to deploy your your distributed application to a kubernetes cluster

Syllabus

Let's go over what we'll cover, and install the software we'll need.

An overview of Microservices and what we'll cover in this course.

Just a bit of information about me and my background.

Read more

Obviously we'll need Go installed on our system, so let's make sure we have it installed, and have the latest version.

If you don't have an IDE, Visual Studio Code will do the job.

Installing make will make our lives easier, so let's take care of that now.

We'll be using Docker extensively in this course, so let's get it installed.

I don't mind helping at all, but make it easy for me to help you.

Mistakes are part of the software development process. I'll make some, and I won't hide them.

Let's put together a simple front end and one microservice, and make sure that the two can talk to each other.

Just an overview of our goals for this section: create a front end application, set up a broker service, and make running that service in Docker very simple.

Let's install some starter code, and set up a Workspace in Visual Studio Code.

Let's take a quick run through of the front end source code and see how it works.

Let's get started writing the code for our Broker microservice.

We have to build a docker image for our Broker services, so let's create a Dockerfile for it, and then get it running in Docker by writing and running a docker-compose.yml file.

Let's go back to the front end application and write the necessary HTML and JavaScript to hit the Broker microservice, just to make sure that everything works as expected.

Let's make it easier to work with JSON by building helper functions to read and write JSON files, and one to send an error message back as JSON when things go wrong.

Let's set up a Makefile that will make it simple to bring our Docker images up, take them down, build our front end, build our microservices, and start and stop the front end.

Let's get a Makefile up and running for Windows users.

Let's set up another microservice. This time, we'll create a simple Authentication service. It can be called directly, or it can be called via the Broker service.

An overview of our goals for this section: implementing an Authentication microservice which is backed by a Postgres database, modifying the Broker service to accept a standard request payload, and making sure that everything works as expected.

Let's get started writing a minimal version of our authentication service.

Let's write the code necessary to connect our Authentication service to a Postgres database.

A note about PostgreSQL

We need to add the authentication microservice to docker compose, as well as Postgres. Let's take care of that now.

Let's put some data in our database, so that we have something to authenticate against.

Our service requires both a route and a handler in order to be useful, so let's write that now.

We need to make some changes to our Broker microservice: first, we have to design a standard JSON format that we'll use for every call to the service; and second, we need to implement a route and handler that will take care of having the broker contact the Authentication service, get a response, process it, and send the appropriate response back to the end user.

The moment of truth is up on us: let's update the front end to hit our authentication service through the broker, and see if it works as expected.

Let's build a logger service, and connect to it from our broker service.
What we'll cover in this section

Let's get started writing some code for our Logger microservice.

We'll need some code that will allow Go to interact with our Mongo database, so let's get started writing a data package for our logger microservice.

Let's finish up writing the database functions that will allow us to interact with the logs collection in our Mongo database.

Let's get our Logger microservice to the point where it can accept and process requests.

Let's get a local instance of MongoDB running through Docker, and try to compile and run the logger service.

Let's modify our Makefile and docker-compose.yml files to get the logger-service up and running in Docker.

We need to update the broker to handle requests that log information to MongoDB through the Logger microservice. Let's take care of that now.

Now that we have the Broker microservice updated, let's write some JavaScript on the front end application in order to test things out.

While we're at it, we might as well implement logging in the Authentication microservice, so that we can log authentication requests.

Let's try out our new functionality and make sure that it works as expected.

Let's set up a Mail microservice that receives a JSON payload, and creates and sends an email using predefined templates.

In this section, we'll set up a mail microservice that allows us to send email from any of our other services, and to use custom email templates when doing so.

We're going to need some kind of mail server to send email through, and Mailhog will do the job. Let's add it to our docker-compose.yml file.

Let's get the basic code in place for our Mailer microservice.

Let's take care of the code that actually sends email. We'll build a system that allows us to send a message with two versions: plain text, and formatted HTML.

In order to take advantage of the Mail and Message type, we'll need to modify main.go, add a route to routes.go, and create a handler. Let's take care of that now.

Let's apply what we've learned. I'm going to ask you to add the new Mail microservice to our docker-compose.yml, to our Makefile, and to create the necessary dockerfile. Give it a try.

Here's how I did the challenge.

Let's modify the Broker microservice to accept a JSON payload which will be sent off to the Mail microservice.

Let's add some JavaScript and a button to the front, and make sure that everything works as expected.

A note about mail and security
Let's set up another way to communicate between microservices using AMPQ, with RabbitMQ and a Listener service.

In this section, we'll build a queue that implements the Advanced Messaging Queue Protocol (AMQP), and push events to that queue. We'll also build a Listener microservice that receives events from the queue, consumes them, and calls a microservice based on the content found in that event.

Let's build a stub version of our Listener microservice.

We'll need an instance of RabbitMQ added to our docker-compose.yml file, so let's take care of that now.

Let's update our Listener microservice so that it connects to RabbitMQ.

In order to interact with RabbitMQ, we'll need to write a few functions. Let's take care of that now.

Let's write a function that will call the Logger microservice from the Listener microservice when we receive a message from RabbitMQ telling us to do so.

Updating main.go to start the Listener function

Let's update the URL to RabbitMQ in our Listener service's main.go file.

Let's create a Dockerfile for the listener service, update the Makefile, and bring up our images.

The Broker service has to be able to interact with RabbitMQ before it can emit events to the queue. Let's get started setting that up now.

Our Broker service is going to need some means of pushing (or publishing) events onto the queue, so let's take care of writing that functionality now.

Let's write a new function in the Broker that will push events (emit them) to RabbitMQ.

Let's give things a try, and fix any mistakes that I might have made along the way.

Let's improve our microservices by allowing events to be pushed between services using Remote Procedure Calls, known as RPC.

In order to handle RPC calls, our Logger microservice has to be able to receive them. Let's get started.

Let's update our Logger microservice to listen for RPC connections.

Before we can try things out, we'll need to modify the Broker service to send an RPC request to the Logger service. Let's take care of that now.

Let's try things out, and see if our RPC client and server behave as expected.

Speeding things up (potentially) with gRPC

On overview of what we are going to cover in this section.

Working with gRPC requires that we have the necessary tooling installed. Let's take care of that now.

The .proto file is at the heart of the gRPC process. It defines the kinds of data we are going to pass around, and it exposes the functions we want to be made available to gRPC. Let's write one for our Logger microservice.

Let's take advantage of the tools we installed and the .proto file we wrote to have gRPC automatically generate some source code for us.

Let's get started writing the code for our gRPC server. We'll start by implementing the one function we exposed in our logs.proto file: WriteLog().

Now that we have the server code in place, let's start listening for gRPC connections.

We need to update the Broker microservice to make a gRPC request to the Logger microservice. Let's take care of  that now.

In order to try things out, we'll need to add some HTML and JavaScript to the front end. Let's take care of that now.

Let's try things out, and see if our gRPC client and server behave as expected.

Let's containerize our application, push it to Docker Hub, and run everything in a Docker Swarm.

An overview of Docker Swarm, and why it is a good alternative to Kubernetes for small teams and individual developers.

In order to take full advantage of Swarm, we'll need to push our Docker images to Docker Hub. Let's take care of building and tagging the images now.

Swarm needs a deployment file, much like a docker-compose.yml file. Let's build one.

Let's initialize Docker swarm, and start up our deployment.

Let's start up the front end application, and try hitting our swarm.

One of the great advantages of Docker swarm, or any container orchestration service, is that we can have multiple instances of our services running at the same time. Let's try scaling a few services up and down.

When you make an update to your code base for any microservice, you'll need to update the docker image for that service, and then update your Docker swarm. You can actually do that with no downtime in most cases. Let's give it a try.

Here is how you can stop, and optionally entirely delete, your Docker swarm.

In order to put everything in our Docker swarm, we'll need to make a few changes to the front end and the Broker, and build a docker image for the front end. Let's get started.

Here is how I solved the challenge.

Let's add our new front end Docker image to the Docker Swarm file as a new microservice.

Right now, we have no means of accessing the front end or the Broker service. Let's fix that by building a custom Caddy Dockerfile, and adding it to the Docker swarm.

Let's add an entry to our local hosts file, and try bringing up the Docker Swarm.

A challenge: let's fix a problem with a URL in our application.

Here's how I solved the challenge.

Updating Postgres to 14.2 - why monitoring is important!

There are lots of providers out there who offer Virtual Private Servers, including Digital Ocean, Linode, Vultr, and many more. I'm going to use Linode, but the process is nearly identical regardless of the provider you choose. Let's set up two new servers on Linode.

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Develops modular, loosely coupled architectures for web applications, which is the current industry standard
Introduces microservices, a key element in the development and maintenance of large-scale web applications
Provides ample hands-on experience with containerization using Docker Swarm and Kubernetes, both widely adopted tools in the industry
Taught by Trevor Sawler, an experienced software engineer who specializes in microservices and distributed systems
Covers advanced topics such as gRPC and message queuing, which are commonly used in modern microservice architectures
May require prior knowledge of containerization and basic web development, making it suitable for intermediate or experienced learners

Save this course

Save Working with Microservices in Go (Golang) to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Working with Microservices in Go (Golang) with these activities:
Organize and review course materials
Organize and review course materials to prepare for the course and reinforce learning
Show steps
  • Gather all of the course materials, such as notes, assignments, and quizzes
  • Organize the materials into a logical structure
  • Review the materials to identify any areas where you need additional support
Review application development fundamentals
Review the basics of application development and web development to prepare for the course
Browse courses on Programming Fundamentals
Show steps
  • Review the fundamentals of programming, including data types, variables, and control flow
  • Review the basics of web development, including HTML, CSS, and JavaScript
Complete the introductory microservices tutorial
Complete the introductory microservices tutorial to learn the basics of microservices
Browse courses on Microservices
Show steps
  • Follow the tutorial to set up a basic microservices environment
  • Complete the tutorial to create a simple microservice
Four other activities
Expand to see all activities and additional details
Show all seven activities
Practice writing simple microservices
Practice writing simple microservices to reinforce the concepts learned in the course
Browse courses on Microservices
Show steps
  • Create a simple microservice that performs a single task, such as generating a random number
  • Create a simple microservice that communicates with another microservice
Build a simple microservices application
Build a simple microservices application to demonstrate your understanding of microservices
Browse courses on Microservices
Show steps
  • Design the architecture of the microservices application
  • Create the individual microservices
  • Deploy the microservices application
Participate in a microservices hackathon
Participate in a microservices hackathon to test your skills and learn from others
Browse courses on Microservices
Show steps
  • Find a microservices hackathon to participate in
  • Form a team and brainstorm ideas
  • Develop and deploy a microservices application
Mentor other students in microservices
Mentor other students in microservices to reinforce your understanding of the topic and help others learn
Browse courses on Microservices
Show steps
  • Identify students who are struggling with microservices
  • Provide guidance and support to these students
  • Create resources and materials to help students learn about microservices

Career center

Learners who complete Working with Microservices in Go (Golang) will develop knowledge and skills that may be useful to these careers:
Cloud Architect
Cloud Architects design and build cloud-based solutions that meet complex business requirements. This course can help those who are interested in a career as a Cloud Architect to build a solid foundation in microservices, and will help them with deploying these kinds of applications to most major cloud platforms.
Software Developer
Software Developers are responsible for creating and maintaining applications. This course can help teach those with experience in other areas of software development to build and run microservice applications.
DevOps Engineer
DevOps Engineers need to be able to build, deploy, and manage distributed systems reliably and securely. This course can be a very useful tool for DevOps Engineers that need to be able to build out and manage clusters of distributed microservices applications, or just want to better understand how these kinds of applications are built and deployed.
Backend Developer
Backend Developers work primarily on the server-side of applications. For those who have experience working in frontend applications, this course may be helpful for learning how to implement and manage the back end of applications using microservices architectures.
Full-Stack Developer
Full Stack Developers can work on both the front and back end of applications. This course can help those who have experience in frontend development to better understand the back end of applications built on top of microservices architectures.
Software Architect
Software Architects design and build large scale, reliable software systems. This course can be very useful for Software Architects who need to learn about designing and building systems with microservices, or who may need to integrate Microservices applications into an existing software ecosystem.
Cloud Security Engineer
Cloud Security Architects are responsible for designing and implementing security measures for cloud-based applications and resources. For those interested in pursuing a career as a Cloud Security Engineer, this course may be useful for building a foundation in microservices applications that run on many cloud providers.
Systems Engineer
Systems Engineers research, design, develop, and implement complex IT systems. Many Systems Engineers work in developing the kind of distributed applications this course teaches students to build, and so this course can be a big help to career Systems Engineers. This course covers everything from building a solid foundation in microservice architecture to deploying to both Docker Swarm and Kubernetes, which may be useful for those that are new to these technologies. This is an especially useful course for those wanting to build a foundation in developing Microservices applications.
Site Reliability Engineer
Site Reliability Engineers maintain and oversee the reliability of the production software systems that keep their company operating. This course can be a useful tool for SREs as it teaches everything from the building blocks of microservices applications to deploying them and managing them as a cluster.
Data Engineer
Data Engineers build and maintain the systems that make data processing and analysis possible. This course is a useful foundation for those who want to build systems to enable modern data applications that take advantage of microservices.
Database Administrator
Database Administrators implement and maintain the database systems that companies use to store and manage their data. This course can help those who are working as a DBA, or those who are interested in a DBA role, to integrate microservices into their systems, or to better understand the applications that they work to support.
Mobile Developer
Mobile Developers are responsible for creating many types of applications. This course can help those with experience in mobile development build server-side systems for their applications using microservices.
Information Security Analyst
Information Security Analysts implement security controls to protect companies and organizations from hackers and cyber threats. This course can help those who want to become an Information Security Analyst to better understand the microservices applications that they will need to secure in the field.
Security Analyst
Security Analysts implement and maintain security measures for companies or teams. This course can teach those interested in becoming Security Analysts some of the underlying technologies that will need to be secured in the field, and may be useful for those interested in securing microservices applications.
Network Engineer
Network Engineers are responsible for the maintenance, design, and implementation of networks for companies and organizations. For those who are interested in pursuing a career as a Network Engineer, this course may be useful for learning how microservices applications work on networks.

Reading list

We've selected 11 books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Working with Microservices in Go (Golang).
Provides a comprehensive overview of Kubernetes. It great resource for anyone who wants to learn more about Kubernetes and how to use it to manage containerized applications.
Provides a practical guide to building microservices. It covers topics such as microservice architecture, design patterns, and testing. It great resource for anyone who wants to learn how to build microservices in a real-world setting.
Provides a comprehensive overview of the Go programming language. It great resource for anyone who wants to learn more about Go and how to use it to build real-world applications.
Provides a quick reference to the Go programming language. It great resource for anyone who wants to have a handy reference to the Go syntax and standard library.
Provides a comprehensive overview of Kubernetes. It great resource for anyone who wants to learn more about Kubernetes and how to use it to manage containerized applications.
Provides a comprehensive overview of microservices, including their benefits, challenges, and best practices. It great resource for anyone who wants to learn more about microservices and how to use them in their own projects.
Provides a comprehensive overview of RabbitMQ. It great resource for anyone who wants to learn more about RabbitMQ and how to use it to build and deploy message-driven applications.
Provides a comprehensive overview of Docker. It great resource for anyone who wants to learn more about Docker and how to use it to build and deploy applications.
Provides a catalog of design patterns. It great resource for anyone who wants to learn about different ways to design and implement software.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Working with Microservices in Go (Golang).
Building Scalable Java Microservices with Spring Boot and...
Most relevant
Build and Implement Microservices Patterns
Most relevant
Monolith to Microservices at Scale
Most relevant
Deploy Microservices using Spring Cloud Framework
Most relevant
Scaling Applications with Microservices and NServiceBus 6
Most relevant
Understanding the Programming Models of Azure Service...
Most relevant
Building Microservice Platforms with TARS
Most relevant
AWS Messaging Services Overview
Most relevant
Introduction to Amazon Simple Queue Service (SQS)
Most relevant
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser