Exploring Routing and Networking in SAP BTP, Cloud Foundry Runtime

Objective

After completing this lesson, you will be able to explore routing and networking in SAP BTP, Cloud Foundry runtime.

Routing and Networking in Cloud Foundry Runtime

Your company is transitioning to a microservices architecture on SAP BTP, Cloud Foundry runtime. As a developer or system administrator, you need to understand how Cloud Foundry manages application routing and networking to ensure seamless communication between microservices and external clients. This lesson will guide you through the fundamentals of routing, custom routes, and microservice communication in SAP BTP, Cloud Foundry runtime.

Routing Fundamentals in Cloud Foundry

Routing in Cloud Foundry is the process of directing incoming HTTP/S traffic to the correct application instance. It serves as the backbone of communication between applications and users, ensuring seamless delivery of web content and services.

Routes and Domain Mapping

Routes in Cloud Foundry are essentially URLs that enable end users to reach your applications. They map domain names to specific applications. An HTTP route includes a domain, a host name (or subdomain), and an optional path.

There are several ways to map routes to your applications in Cloud Foundry:

  • You can map a route to an app with the cf push command. As of cf CLI v7, the best way to do this is by using the routes property in the manifest.
  • You can use: --random-route flag with cf push or use random-route: true in the manifest to create a random route for the app.
  • You can manually create and map routes to an existing application via the create-route and map-route command with the CF CLI, or in the BTP cockpit. If the route doesn't exist, the map-route command will create it and map it to the application. When mapping an existing route to an application, route and application must be in the same CF Space.

In SAP BTP, it's also possible to map a single route to multiple applications, as well as multiple routes to a single application. This feature can be particularly useful in scenarios where you want to distribute traffic between different instances of an application or when you want to expose different functionality of a single application under different routes. For further information, see Configuring routes and domains.

Load Balancing and Traffic Distribution

By default, the Gorouter uses a round-robin algorithm for load balancing of requests across application instances. This means that each incoming request is sent to the next application instance in the list, looping back to the first instance after the last one has been reached. This approach distributes traffic evenly across multiple instances, preventing overload and maximizing resource utilization. This ensures consistently high application performance and a smooth, efficient user experience. For further information, see also Router balancing algorithm

Cloud Foundry also supports session affinity, also known as sticky sessions, allowing all requests from a specific client to be directed to the same application instance. This is beneficial for applications that require state maintenance between requests. However, session affinity is typically used for legacy applications and is not the preferred pattern for modern application architectures. For further information, please consult the documentation on Session affinity.

Custom Domains

You can use custom domains in Cloud Foundry, and assign routes on these domains to your applications. For more information, check this document.

Summary

This lesson explored routing and networking in Cloud Foundry, a crucial aspect of deploying and managing applications within the platform. You learned about the role of the Gorouter as the entry point for external traffic and how routes map domain names to specific applications. You delved into load balancing to distribute traffic efficiently across application instances. You then learned how to create and manage custom routes, refining them with hostnames and paths to tailor traffic flow.

Log in to track your progress & complete quizzes