Lightweight Java in the Cloud
-
Upload
shaun-smith -
Category
Technology
-
view
424 -
download
2
Transcript of Lightweight Java in the Cloud
![Page 1: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/1.jpg)
Lightweight Java in the Cloud
Shaun Smith Oracle Applica9on Container Cloud [email protected] @shaunMsmith Gerrit Grunwald Java Technology Evangelist [email protected] @hansolo_
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
![Page 2: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/2.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement The following is intended to outline our general product direc9on. It is intended for informa9on purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or func9onality, and should not be relied upon in making purchasing decisions. The development, release, and 9ming of any features or func9onality described for Oracle’s products remains at the sole discre9on of Oracle.
2
![Page 3: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/3.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java Cloud • Java SE is ideal for building lightweight applica9ons and (micro)services • Cloud plaTorms offer – High availability – Affordability – Ease of management – Access to suppor9ng services like object storage, messaging, and databases
3
![Page 4: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/4.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
What do we mean by Cloud? • A wonderfully amorphous word! • Clouds offer a range of services including Iaas / SaaS / PaaS
• Applica9on PlaTorm as a Service—APaaS – Focused on running lightweight applica9ons—not heavy weight services like database – Typically employ containers to run applica9ons – Many vendors to choose from – Most, if not all, APaaS plaTorms support Java
4
![Page 5: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/5.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Cloud Applica9on Architecture
5
![Page 6: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/6.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 6
![Page 7: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/7.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 7
Configura9on
![Page 8: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/8.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Test Prod
8
Dev
![Page 9: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/9.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Configura9on • Applica9on should be “parameterizable”—externalize all config data • Configura9on should be defined as environment variables and read by applica9ons on start • Makes it easy to deploy the applica9on to any environment where configura9ons will differ • Deployment configura9on can be managed by Ops post Dev
9
![Page 10: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/10.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 10
This includes database and other backing service loca9ons, third-‐party creden9als like AWS or Twijer…such configura9on should not be stored in the codebase…exposes private resources in the version control system.
![Page 11: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/11.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 11
Environment variables…useful when the values are likely to be different from one host system to the next…makes the applica9on code more portable and flexible…cri4cal for wri4ng applica4ons that are easily deployed and scaled
![Page 12: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/12.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 12
Grizzly / Jersey
![Page 13: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/13.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 13
Embedded Tomcat
![Page 14: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/14.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 14
Configura9on
Dependencies
![Page 15: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/15.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Dependencies
• Applica9on dependencies must be explicitly declared • Relying on the availability of system wide libraries in the run9me environment can lead problems that are to hard to diagnose • Applica9ons with explicit dependencies are easy to move between environments • Maven & Gradle provide a nice way to declare applica9on dependencies
15
![Page 16: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/16.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 16
Configura9on
Dependencies
Service Interface
![Page 17: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/17.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Service Interface • Cloud applica9ons typically expose Web/REST/Websocket services using embedded servers like Tomcat, Jejy, or Grizzly/Jersey/Tyrus. • Embedded servers must bind to the hostname and port defined by the run9me environment, typically in an environment variable like $PORT • Applica9ons running in containers will likely bind to a local port that is receiving load balanced traffic forwarded from a pubic port • By exposing func9onality over REST, applica9ons can be provide services to other applica9ons (the core of the microservices approach)
17
![Page 18: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/18.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 18
Configura9on
Dependencies Services
Applica9on Interface
![Page 19: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/19.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Service Dependencies • Service coordinates published in the run9me environment for consump9on by applica9on • Backing services should be pluggable • Easy to change services—restart applica9on to pick up changes • Treat 3rd party or plaTorm services the same as your own services
19
![Page 20: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/20.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
DEMO
20
![Page 21: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/21.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Cloud Applica9on Quali9es
21
![Page 22: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/22.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Stateless / Disposable • Applica9ons should be stateless with all persistent data stored in external services like database or key/value stores • Stateless applica9ons makes scaling easy (esp. when scaling in by disposing of instances) • Configura9on changes will result in the restar9ng (disposing & crea9ng) of applica9on instances • Ephemeral disk is useful but there is no guarantee a subsequent request will be handled by the same instance
22
![Page 23: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/23.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Share Nothing • Ideally, applica9ons should be stateless and share-‐nothing • Horizontal scaling of stateless applica9ons by adding instances to handle increased load is simple and reliable • Not everyone agrees on this point…
23
![Page 24: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/24.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 24
Why We Aren’t Joining the Cloud Foundry Founda4on
…we are also working hard to support both stateless and stateful applica9ons inside those containers…
![Page 25: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/25.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 25
Concurrency in Oracle Java SE Cloud Service
Java SE
Docker
Java SE
Docker
Load Balancer …
Messaging Cloud Service
Storage Cloud Service
Database Cloud Service
Java Cloud Service
MyApp
Java SE
Docker
![Page 26: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/26.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Prac9cal Majers
26
![Page 27: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/27.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Development vs. Deployment • APaaS plaTorms are deployment plaTorms—you run apps on them • Development happens where? • How to develop and debug applica9ons targe9ng APaaS?
27
![Page 28: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/28.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Debug locally in emulated environment • Define environment variables to match target
• Use same JDK release and version as in target
• Use tools like Foreman
• Challenge—”emulated” not iden9cal
Debug in Cloud • Restrict to single instance • Remote test & debug
• E.g., Spring Tools (experimental afaik)
• Challenge—opening up ports and suppor9ng breakpoint callbacks from cloud to desktop
28
Debug locally using same Docker image as on APaaS • Same run9me environment as Cloud
• Challenge—dependency on cloud services
• E.g. Heroku (not exactly the same since not Docker in cloud)
Java APaaS Debug Op9ons
![Page 29: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/29.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Summary • Java is one of the best choices for Cloud applica9on development • Java has broad support from APaaS vendors • Most of the architectural principals of Cloud apps are simply good prac9ce – Configurable – Declared Dependencies – Pluggable Service – …
29
Configura9on
Dependencies
Applica9on Interface
Services
![Page 30: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/30.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java is the PlaTorm! • Focus on your Java applica9on and not on proprietary plaTorm features • Architect for plaTorm independence • Own the stack—don’t let vendors dictate • Use embedded servers, not containers to stay light • Consider the microservices approach of many small services assembled to provide a complete solu9on
30
![Page 31: Lightweight Java in the Cloud](https://reader031.fdocuments.in/reader031/viewer/2022030300/5881016a1a28abc3368b75fb/html5/thumbnails/31.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 31