TCP routing in the application cloud

App Cloud

TCP routing in the application cloud

The Swisscom Application Cloud, which is based on the open source industry standard Cloud Foundry, offers its users an exciting new feature. TCP routing, the ability to support any TCP-based, non-HTTP-based application and make it accessible to the world. Let's take a closer look and learn how to use TCP routing.

The Swisscom Application Cloud based on Cloud Foundry(opens in new tab), the leading open source industry standard for building your own platform-as-a-service.

One of the many great features that Cloud Foundry offers is TCP routing, i.e. the ability to route and expose any TCP-based traffic from your application to the outside world.

TCP routing in Cloud Foundry is based on reserving ports on a TCP router group for an application that is mapped to a TCP route and domain, which is then provisioned by a front-end load balancer like our F5. Incoming traffic from a client on this port is forwarded to the container instances of your application using a round-robin load balancing policy. TCP router groups are a collection of multiple Cloud Foundry TCP routers that ensure high availability.

TCP Routing enables you to bring applications into the Application Cloud that you would never have thought of before.

For example, you could Memcached(opens in new tab) as an app, an in-memory cache that communicates via TCP:

$ cf push -o memcached memcached

Creating app memcached in org swisscom /
space examples as user1...

OK 

...

Showing health and status for app

memcached in org swisscom / space

examples as user1...

OK

requested state: started

instances: 1/1

usage: 1G x 1 instances

urls: memcached.scapp.io

state since cpu memory disk details

#0 running 2018-03-05 12:31:31 PM 0.0%
0 of 1G 0 of 1G

And all you have to do now to publish it via TCP is to bind a TCP route and specify the port via which it should reach the outside world:

$ cf map-route memcached tcp.scapp.io --
port 35666

Creating route tcp.scapp.io:35666 for

org swisscom / space examples as
user1...

OK

Adding route tcp.scapp.io:35666 to app

memcached in org swisscom / space
examples as user1...

OK

Your application should now be accessible via TCP port 35666 on the domain tcp.scapp.io.

Let's check whether this actually works by using Telnet to establish a TCP connection to our application on this domain and this port:

$ telnet tcp.scapp.io 35666

Trying 211.222.233.100...

Connected to tcp.scapp.io.

Escape character is '^]'.

set greeting 1 0 11

Hello World

STORED

quit

Connection closed by foreign host. $ telnet tcp.scapp.io 35666

Trying 211.222.233.100...

Connected to tcp.scapp.io.

Escape character is '^]'.

get greeting

VALUE greeting 1 11

Hello World

END

quit

Connection closed by foreign host.

Another interesting type of application that is possible thanks to TCP routing would be a game server that also only communicates via TCP.
Let's try this out with 
Minecraft(opens in new tab):

$ cf push minecraft -o itzg/minecraft-
server -i 1 -m 1536M --no-start 

$ cf create-route examples tcp.scapp.io
--port 28888 $ cf map-route mcs tcp.scapp.io --port 28888 

$ cf set-env mcs EULA true

$ cf set-env mcs MOTD 'Minecraft powered
by Swisscom Application Cloud' 

$ cf start minecraft $ cf app minecraft
Showing health and status for app
minecraft in org swisscom / space
examples as user1... name: minecraft
requested state: started

instances:                       1/1

usage:                              1.5G x 1 instances

routes:                             tcp.scapp.io:28888

last uploaded:               Mon 12 Feb 15:26:23 UTC 2018

stack:                              cflinuxfs2

docker image:               itzg/minecraft-serverstate             sincecpu       memory              disk
details
#0        running     2018-03-28T22:44:18Z
1.2%        959.5M     of     1.5G     35.2M   of   1G

There you have it, Minecraft runs in the Application Cloud:

Operating a Minecraft server on the Application Cloud would not have been possible before, as it only works via TCP.

Of course, a persistent file system is also missing here, so your world will be lost as soon as your application is restarted. But we also want to solve this problem soon by making Volume Services available to you. (A small foretaste of the future!)

To use the TCP routing feature in our public Application Cloud offering, simply send us a support request telling us what you want to use it for. We look forward to enabling the appropriate quota settings for your organisation so that you can push TCP-based applications to the cloud.

For more information on using TCP routing from an end-user perspective, please see our documentation:
https://docs.developer.swisscom.com/devguide/deploy-apps/routes-domains.html#create-route-with-port(opens in new tab)

Fabio Berchtold

Fabio Berchtold

Senior Cloud Engineer

More getIT-articles

Ready  for  Swisscom

Find the job or career to suit you. A career where you can make a difference and continue your personal development.

What you do is who we are.

Go to careers

Go to current cyber security vacancies