Reader small image

You're reading from  Arduino Data Communications

Product typeBook
Published inNov 2023
PublisherPackt
ISBN-139781837632619
Edition1st Edition
Right arrow
Author (1)
Robert Thas John
Robert Thas John
author image
Robert Thas John

Robert Thas John is a data engineer with a career that spans two decades. He manages a team of data engineers, analysts, and machine learning engineers – roles that he has held in the past. He leads a number of efforts aimed at increasing the adoption of machine learning on embedded devices through various programs from Google Developers and ARM Ltd, which licenses the chips found in Arduinos and other microcontrollers. He started his career as a software engineer with work that has spanned various industries. His first experience with embedded systems was in programming payment terminals.
Read more about Robert Thas John

Right arrow

Scaling for High Availability

When you go from the prototype stage to a full-fledged release of your hardware, you will be faced with demands on your computing infrastructure. In this chapter, you will learn about the various demands that are placed on computing resources as you scale, and the various options for meeting this demand as your users continue to grow.

In this chapter, we will cover the following topics:

  • Understanding high availability
  • Understanding load balancing
  • Implementing high availability for databases
  • Implementing high availability for RESTful servers

Let’s begin!

Understanding high availability

High availability (HA) refers to a characteristic of a computing system that aims to provide an agreed level of performance. This normally refers to the proportion of time that the system is available and is given in terms of a percentage. You can convert this percentage into the number of days in a year that the system is guaranteed to be available, or conversely, the maximum number of days in a year during which the system can be down or unavailable.

For example, if the availability of a system is given as 95%, then the system is guaranteed to be available for approximately 347 days in a year and could be unavailable for up to 18 days in a year. Does that sound good?

The answer to that question, like everything, is “It depends.” A continuous 18-day outage could lose you customers, but when you look at it from a monthly perspective, that would translate to an average outage of 1.5 days every month. Does that sound acceptable? That...

Understanding load balancing

You can set up load balancing using a compute cluster. This is a collection of identical servers, called nodes, that run the same operating system and software. The load balancer is a server that sits in front of the cluster and directs traffic to individual nodes. An example is illustrated in the following diagram:

Figure 13.1 – Load balancing

Figure 13.1 – Load balancing

The nodes are connected on a single high-speed network that they use for communication and sharing resources. The load balancer keeps track of which nodes are available and sends traffic to them.

In some situations, you can make use of load balancing to provide redundancy and failover while also minimizing expenses.

You can minimize expenses by shutting down nodes when you don’t need them and starting them up when you do. There are two reasons why you would want to take this approach:

  • In a physical data center, more nodes running means higher energy and cooling...

Implementing HA for databases

HA for databases is the ability of a database system to continue operating even if one or more of its components fail. This is critical for databases that are used for essential applications. There are various ways of accomplishing this:

  • Replication: This involves creating multiple copies of the database and storing them on different servers. If one server fails, the other servers can continue to provide access to the database.
  • Failover: This involves having a standby server that is ready to take over if the primary server fails. The standby server can be kept in sync with the primary server in real time, or it can be updated periodically.
  • Load balancing: This involves distributing the workload across multiple servers. This can help improve performance and availability as it reduces the load on any single server.
  • Clustering: This involves grouping several servers so that they work together as a single system. This can help improve performance...

Implementing HA for RESTful servers

A RESTful server is a web server that makes API endpoints available for consumption. There are various web servers, such as Apache and NGINX, and configuring each one is different.

To implement HA for a web server, you must implement a proxy server in front of the web servers that you will be setting up. In this scenario, the web servers will all make use of the same static files and assets, which will be deployed in a central location. If there is a need for a database connection, then the database server will be hosted separately. Rather than connecting to individual web servers, all traffic is directed to the load balancer, which then distributes traffic. That is how all major websites function.

One of the considerations for a load balancer is how to distribute traffic to the nodes within your cluster. Some common methods in use are as follows:

  • Round-robin: In this approach, traffic is distributed evenly. For example, if you have...

Summary

In this chapter, you learned about the need to have a setup that is going to be available when the demand for your services increases. You learned about HA and load balancing, and you learned how to make your database and web application servers more redundant and highly available.

In the next chapter, you will learn how you can take your breadboard circuits and manufacture them.

Further reading

To learn more about the topics that were covered in this chapter, take a look at the following resources:

  • Implementing HTTP load balancing with NGINX: https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/
  • Implementing HTTP load balancing with Apache: https://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html
  • GCP cloud load balancing: https://cloud.google.com/load-balancing/docs/load-balancing-overview#a_closer_look_at_cloud_load_balancers
  • GCP – creating a Compute Engine instance: https://cloud.google.com/compute/docs/instances/create-start-instance
  • GCP – creating firewall rules: https://cloud.google.com/firewall/docs/using-firewalls
  • Installing Apache on GCP: https://cloud.google.com/compute/docs/tutorials/basic-webserver-apache
  • GCP – configuring a network load balancer: https://cloud.google.com/load-balancing/docs/network
  • MySQL replication: https://dev.mysql.com/doc/refman/8.0/en/replication...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Arduino Data Communications
Published in: Nov 2023Publisher: PacktISBN-13: 9781837632619
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
Robert Thas John

Robert Thas John is a data engineer with a career that spans two decades. He manages a team of data engineers, analysts, and machine learning engineers – roles that he has held in the past. He leads a number of efforts aimed at increasing the adoption of machine learning on embedded devices through various programs from Google Developers and ARM Ltd, which licenses the chips found in Arduinos and other microcontrollers. He started his career as a software engineer with work that has spanned various industries. His first experience with embedded systems was in programming payment terminals.
Read more about Robert Thas John