Home » What is PORT BINDING?

What is PORT BINDING?

The sixth factor in a 12-factor app is that the app should “export services via port binding.” Port binding improves an application’s portability and security. Subsequently, it makes it easier to work with by allowing multiple processes to communicate on their own port.

This is the seventh video in our 12-factor Application Modernisation series. In this video, Marc Firth (Managing Director at Firney) explains software engineering best practices for building scalable, reliable web services that are efficient to work with.

See our Application Modernisation with 12-Factor App series and the full App Modernisation playlist on YouTube.

A transcript of the video above is included below.

Make your applications portable

Firstly, when managing scalable applications, we want them to be flexible and secure. In addition, we also want them to be efficient in the way that we work with them.

In this video, we’re going to go through how and why we use port binding. This will improve an application’s portability and security and make it easier to work with.

So, let’s dig into that.

The 12-factor app

This is our 12-Factor app series on application modernisation. In this series, we talk about how to make applications more reliable, scalable and efficient.

Self-contained processes are key

Apps should be self-contained, independent processes. They should not run under the control of a parent process.

For example, let’s say we want to create a web-facing service. A 12-factor app does not rely on the runtime injection of a web server into the execution environment.

One of the benefits of port bonding is that it enables us to specify an internal and an external port.

For instance, we might have a distributed app with three different web services running on Port 80. We can map those services to three different ports, such as 3000, 3001 and 3002. By doing this, it enables us to direct traffic to those ports independently.

You can port bind any service

Let’s use a web app as our example.

We export HTTP as a service by binding to a port and listening to requests coming in on that port. HTTP isn’t the only service that can be exported by port binding. Nearly any kind of service software can be run via a process binding to a port and awaiting incoming requests.

We map traffic to all of these processes via a routing layer that is put behind a load balancer. A Google load balancer can even map traffic directly to a Kubernetes pod. This, in turn, is connected to a container using “container-native load balancing”. It’s this architecture that enables us to scale more effectively.

Treat services as backing services

Port binding has other benefits too. Exporting services via port binding is that it enables us to treat some services as backing services.

For example, this could help us to in the following ways.

  • Put PHP behind an Nginx web server service to proxy requests (and use Nginx features)
  • Attach APIs
  • Attach other data sources like databases, cache and queues

This consistent approach of using port binding enables us to combine multiple 12-factor apps into a distributed application. Subsequently, this helps improve security because we’re being very specific about which ports can gain access to that container.

However, additional security measures do need to be taken depending on what you’re doing.

How we use Port Binding at Firney

At Firney, port binding and the rest of the 12-factor methodology are our mantra. They have helped us create sites, services, APIs, and landing pages that are highly scalable. These services are used by millions of users every day. They are built using this methodology that enables them to be flexible, secure and efficient to work with.

I hope that helps you on your quest to build better, scalable, manageable and efficient applications. I hope you can use this guidance to make them easier to work with too.

If you found this topic useful, I’d recommend downloading a copy of our application modernisation guide below. It contains best practices for modern cloud & software engineering collated from a wide variety of industry sources.

See you in the next one!

Looking to elevate your online performance?

Get a free review of your cloud to assess the reliability you need and improve performance at scale.

Get your FREE Cloud Review!

( Why not? It’s FREE after all! )

Ready to get started?

Get in touch