SlideShare a Scribd company logo
30/06/17
Copyright @ 2014 ParisJug. Licence CC - Creative Commons 2.0 France – Paternité - Pas
d'Utilisation Commerciale - Partage des Conditions Initiales à l'Identique
www.parisjug.org
Tomcat: from aTomcat: from a
cluster to the Cloudcluster to the Cloud
Tomcat: from aTomcat: from a
cluster to the Cloudcluster to the Cloud
par Jean-Frederic Clere
@jfclere
par Jean-Frederic Clere
@jfclere
30/06/17
30/06/17
AgendaAgenda
●
Who I am
● A cluster:
– Session replication and application.
● The cloud:
– Nope it doesn’t work from scratch.
– External session replication
● Via Infinispan and KubePing
– Modify the tomcat cluster (still not finished)
● AKA dynamic list of nodes
●
Only TCP. (8888 port exported via deployment.yml)
– Demos
● What next? Questions / Suggestions
● Who I am
● A cluster:
– Session replication and application.
● The cloud:
– Nope it doesn’t work from scratch.
– External session replication
● Via Infinispan and KubePing
– Modify the tomcat cluster (still not finished)
●
AKA dynamic list of nodes
● Only TCP. (8888 port exported via deployment.yml)
– Demos
● What next? Questions / Suggestions
30/06/17
Who am I?Who am I?
● Jean-Frederic Clere
● Red Hat
● Years writing JAVA code and server software
● Tomcat committer since 2001
● Doing OpenSource since 1999
● Cyclist/Runner etc
● Lived 15 years in Spain (Barcelona)
● Now in Neuchâtel (CH)
● Jean-Frederic Clere
● Red Hat
● Years writing JAVA code and server software
● Tomcat committer since 2001
● Doing OpenSource since 1999
● Cyclist/Runner etc
● Lived 15 years in Spain (Barcelona)
● Now in Neuchâtel (CH)
30/06/17
A clusterA cluster
INTERNET
INTRANET
Router/Prox
y
6
30/06/17
How to replicate sessionsHow to replicate sessions
● In cluster:
● <distributable/> in web.xml
● <Cluster
className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
● Port upd 45564
● Ports tcp range 4000:4100
● In cluster:
● <distributable/> in web.xml
● <Cluster
className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
● Port upd 45564
● Ports tcp range 4000:4100
7
30/06/17
Demo
HAT
ServerWIFI
HATWIFI
● Number Guest clusterized.● Number Guest clusterized.
HTTP mod_balancerTomcat Tomcat
FireFox / Chrome
OPENSHIFTOPENSHIFT
● A Red Hat project / product
● See OpenShift
https://www.openshift.com/
● Docker 1.4
● Kubernetes 1.12
● A Red Hat project / product
● See OpenShift
https://www.openshift.com/
● Docker 1.4
● Kubernetes 1.12
Tomcat in OpenShiftTomcat in OpenShift
Developping Tomcat App in OpenShiftDevelopping Tomcat App in OpenShift
RHEL RHEL
When a developer
creates a new
application OpenShift
start a new pod
Web Console
Eclipse IDE
Command Line
Master Node Node Node
RHEL
pod
AWS / CloudForms / OpenStack (IaaS) / RHEV (Virt) / Bare Metal
Getting startedGetting started
● minishift:
– Allow to demo on single box.
– Easy to setup
– Small demo
● Bare metal / VM:
– Use ansible to install
– 2 nodes + master minimal
● Tomcat webapp with sessions
– Counter demo.
● minishift:
– Allow to demo on single box.
– Easy to setup
– Small demo
● Bare metal / VM:
– Use ansible to install
– 2 nodes + master minimal
● Tomcat webapp with sessions
– Counter demo.
Session replication in a clusterSession replication in a cluster
● HTTP/1.1
– No transaction
– No persistent connection
● Web App:
– Using cookies to carry session ID
– Store information in the session:
● Shopping cart etc.
● Multi nodes and dynamic
– Route request to right node
– Replicate information
● HTTP/1.1
– No transaction
– No persistent connection
● Web App:
– Using cookies to carry session ID
– Store information in the session:
● Shopping cart etc.
● Multi nodes and dynamic
– Route request to right node
– Replicate information
From a cluster to the CloudFrom a cluster to the Cloud
RHEL RHEL
Broker Node Node Node
RHEL
! Power
COL 1 2 3 4 5 6 7 8 1 2 3 6 25 50 8012
100
10
Ether 10/100
Load balancer Tomcat node Tomcat nodeTomcat node
HTTP
D
Problems for a cluster to cloud...Problems for a cluster to cloud...
● Many ways to solve:
– Embed tomcat with SpringBoot
– Create a docker image
– Extend an existing docker image
– Fabric8
● Tomcat session replication:
– No multicast in the cloud.
– Need a “ping” to find the other nodes
(KubePing)
– Add view to the system account of the
project.
● Many ways to solve:
– Embed tomcat with SpringBoot
– Create a docker image
– Extend an existing docker image
– Fabric8
● Tomcat session replication:
– No multicast in the cloud.
– Need a “ping” to find the other nodes
(KubePing)
– Add view to the system account of the
project.
GoalsGoals
● Have something:
– Minimal modification of the tomcat configuration (server.xml)
– Reuse existing code
● Some code still missing:
– Some in Tomcat
– Documentation / tests.
● Some more stuff:
– We use ansible for the install.
– Some maven builds and shells.
● Have something:
– Minimal modification of the tomcat configuration (server.xml)
– Reuse existing code
● Some code still missing:
– Some in Tomcat
– Documentation / tests.
● Some more stuff:
– We use ansible for the install.
– Some maven builds and shells.
Ismaïl Senhaji, Guillaume P
ythoud
16
30/06/17
SolutionSolution
Tomcat built-in solution
Peer discovery through multicast
heartbeat messages
Does not work in a cloud environment
Sessi
on
Data
Sessi
on
Data
Sessi
on
Data
Sessi
on
Data
Sessi
on
Data
Sessi
on
Data
Multicast
Our solution
Peer discovery through
Kubernetes Downward API
Works in OpenShift
Kubernetes API
Ismaïl Senhaji, Guillaume P
ythoud
17
30/06/17
Kubernetes APIKubernetes API
Tools for managing a
Kubernetes cluster
Accessible from the pods
within the cluster
GET
/api/v1/namespaces/tomcat-in-
the-cloud/pods
➔ Return a JSON representation of all
the pods in the cluster
Tools for managing a
Kubernetes cluster
Accessible from the pods
within the cluster
GET
/api/v1/namespaces/tomcat-in-
the-cloud/pods
➔ Return a JSON representation of all
the pods in the cluster
Ismaïl Senhaji, Guillaume P
ythoud
18
30/06/17
ArchitectureArchitecture
DynamicMembershipService
RefreshThread
● Call memberProvider.getMembers()
● Filter out already known Member
● Inform listeners of
new/dead members
KubernetesMemberProvider
● init():
● Get URL, cert, ... from
environment variables
● Set startTime
● getMembers():
● Call api to get pods
● Filter active pods
● Compute aliveTime
MemberProvider
● init(Properties)
● getMembers(): List<Member>
Where are we?Where are we?
● Main sites:
– https://docs.openshift.com
– https://github.com/Project31
– https://github.com/iSma/tomcat-
in-the-cloud/
● Thanks:
– Université de Neuchâtel
– Kurt Stam
<kstam@redhat.com>
● Main sites:
– https://docs.openshift.com
– https://github.com/Project31
– https://github.com/iSma/tomcat-
in-the-cloud/
● Thanks:
– Université de Neuchâtel
– Kurt Stam
<kstam@redhat.com>
Questions ?
Suggestions?
30/06/17
Titre
Merci !
30/06/17
Titre
Sponsors

More Related Content

Tomcat from a cluster to the cloud on RP3

  • 1. 30/06/17 Copyright @ 2014 ParisJug. Licence CC - Creative Commons 2.0 France – Paternité - Pas d'Utilisation Commerciale - Partage des Conditions Initiales à l'Identique www.parisjug.org
  • 2. Tomcat: from aTomcat: from a cluster to the Cloudcluster to the Cloud Tomcat: from aTomcat: from a cluster to the Cloudcluster to the Cloud par Jean-Frederic Clere @jfclere par Jean-Frederic Clere @jfclere 30/06/17
  • 3. 30/06/17 AgendaAgenda ● Who I am ● A cluster: – Session replication and application. ● The cloud: – Nope it doesn’t work from scratch. – External session replication ● Via Infinispan and KubePing – Modify the tomcat cluster (still not finished) ● AKA dynamic list of nodes ● Only TCP. (8888 port exported via deployment.yml) – Demos ● What next? Questions / Suggestions ● Who I am ● A cluster: – Session replication and application. ● The cloud: – Nope it doesn’t work from scratch. – External session replication ● Via Infinispan and KubePing – Modify the tomcat cluster (still not finished) ● AKA dynamic list of nodes ● Only TCP. (8888 port exported via deployment.yml) – Demos ● What next? Questions / Suggestions
  • 4. 30/06/17 Who am I?Who am I? ● Jean-Frederic Clere ● Red Hat ● Years writing JAVA code and server software ● Tomcat committer since 2001 ● Doing OpenSource since 1999 ● Cyclist/Runner etc ● Lived 15 years in Spain (Barcelona) ● Now in Neuchâtel (CH) ● Jean-Frederic Clere ● Red Hat ● Years writing JAVA code and server software ● Tomcat committer since 2001 ● Doing OpenSource since 1999 ● Cyclist/Runner etc ● Lived 15 years in Spain (Barcelona) ● Now in Neuchâtel (CH)
  • 6. 6 30/06/17 How to replicate sessionsHow to replicate sessions ● In cluster: ● <distributable/> in web.xml ● <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> ● Port upd 45564 ● Ports tcp range 4000:4100 ● In cluster: ● <distributable/> in web.xml ● <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> ● Port upd 45564 ● Ports tcp range 4000:4100
  • 7. 7 30/06/17 Demo HAT ServerWIFI HATWIFI ● Number Guest clusterized.● Number Guest clusterized. HTTP mod_balancerTomcat Tomcat FireFox / Chrome
  • 8. OPENSHIFTOPENSHIFT ● A Red Hat project / product ● See OpenShift https://www.openshift.com/ ● Docker 1.4 ● Kubernetes 1.12 ● A Red Hat project / product ● See OpenShift https://www.openshift.com/ ● Docker 1.4 ● Kubernetes 1.12
  • 10. Developping Tomcat App in OpenShiftDevelopping Tomcat App in OpenShift RHEL RHEL When a developer creates a new application OpenShift start a new pod Web Console Eclipse IDE Command Line Master Node Node Node RHEL pod AWS / CloudForms / OpenStack (IaaS) / RHEV (Virt) / Bare Metal
  • 11. Getting startedGetting started ● minishift: – Allow to demo on single box. – Easy to setup – Small demo ● Bare metal / VM: – Use ansible to install – 2 nodes + master minimal ● Tomcat webapp with sessions – Counter demo. ● minishift: – Allow to demo on single box. – Easy to setup – Small demo ● Bare metal / VM: – Use ansible to install – 2 nodes + master minimal ● Tomcat webapp with sessions – Counter demo.
  • 12. Session replication in a clusterSession replication in a cluster ● HTTP/1.1 – No transaction – No persistent connection ● Web App: – Using cookies to carry session ID – Store information in the session: ● Shopping cart etc. ● Multi nodes and dynamic – Route request to right node – Replicate information ● HTTP/1.1 – No transaction – No persistent connection ● Web App: – Using cookies to carry session ID – Store information in the session: ● Shopping cart etc. ● Multi nodes and dynamic – Route request to right node – Replicate information
  • 13. From a cluster to the CloudFrom a cluster to the Cloud RHEL RHEL Broker Node Node Node RHEL ! Power COL 1 2 3 4 5 6 7 8 1 2 3 6 25 50 8012 100 10 Ether 10/100 Load balancer Tomcat node Tomcat nodeTomcat node HTTP D
  • 14. Problems for a cluster to cloud...Problems for a cluster to cloud... ● Many ways to solve: – Embed tomcat with SpringBoot – Create a docker image – Extend an existing docker image – Fabric8 ● Tomcat session replication: – No multicast in the cloud. – Need a “ping” to find the other nodes (KubePing) – Add view to the system account of the project. ● Many ways to solve: – Embed tomcat with SpringBoot – Create a docker image – Extend an existing docker image – Fabric8 ● Tomcat session replication: – No multicast in the cloud. – Need a “ping” to find the other nodes (KubePing) – Add view to the system account of the project.
  • 15. GoalsGoals ● Have something: – Minimal modification of the tomcat configuration (server.xml) – Reuse existing code ● Some code still missing: – Some in Tomcat – Documentation / tests. ● Some more stuff: – We use ansible for the install. – Some maven builds and shells. ● Have something: – Minimal modification of the tomcat configuration (server.xml) – Reuse existing code ● Some code still missing: – Some in Tomcat – Documentation / tests. ● Some more stuff: – We use ansible for the install. – Some maven builds and shells.
  • 16. Ismaïl Senhaji, Guillaume P ythoud 16 30/06/17 SolutionSolution Tomcat built-in solution Peer discovery through multicast heartbeat messages Does not work in a cloud environment Sessi on Data Sessi on Data Sessi on Data Sessi on Data Sessi on Data Sessi on Data Multicast Our solution Peer discovery through Kubernetes Downward API Works in OpenShift Kubernetes API
  • 17. Ismaïl Senhaji, Guillaume P ythoud 17 30/06/17 Kubernetes APIKubernetes API Tools for managing a Kubernetes cluster Accessible from the pods within the cluster GET /api/v1/namespaces/tomcat-in- the-cloud/pods ➔ Return a JSON representation of all the pods in the cluster Tools for managing a Kubernetes cluster Accessible from the pods within the cluster GET /api/v1/namespaces/tomcat-in- the-cloud/pods ➔ Return a JSON representation of all the pods in the cluster
  • 18. Ismaïl Senhaji, Guillaume P ythoud 18 30/06/17 ArchitectureArchitecture DynamicMembershipService RefreshThread ● Call memberProvider.getMembers() ● Filter out already known Member ● Inform listeners of new/dead members KubernetesMemberProvider ● init(): ● Get URL, cert, ... from environment variables ● Set startTime ● getMembers(): ● Call api to get pods ● Filter active pods ● Compute aliveTime MemberProvider ● init(Properties) ● getMembers(): List<Member>
  • 19. Where are we?Where are we? ● Main sites: – https://docs.openshift.com – https://github.com/Project31 – https://github.com/iSma/tomcat- in-the-cloud/ ● Thanks: – Université de Neuchâtel – Kurt Stam <kstam@redhat.com> ● Main sites: – https://docs.openshift.com – https://github.com/Project31 – https://github.com/iSma/tomcat- in-the-cloud/ ● Thanks: – Université de Neuchâtel – Kurt Stam <kstam@redhat.com>