Spring in the Cloud
-
Upload
eberhard-wolff -
Category
Documents
-
view
6.618 -
download
2
Transcript of Spring in the Cloud
![Page 1: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/1.jpg)
Spring in the Cloud
![Page 2: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/2.jpg)
About me • Eberhard Wolff • Architecture & Technology Manager at adesso • adesso is a leading IT consultancy in Germany • Speaker • Author (i.e. first German Spring book) • Blog: http://ewolff.com • Twitter: @ewolff • [email protected]
![Page 3: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/3.jpg)
Content • What is the Cloud? • My First Cloud App • Scaling the App • Another Cloud Challenge • Java EE 7 • Conclusion
![Page 4: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/4.jpg)
What is the Cloud? Infrastructure
as a Service Platform
as a Service Software
as a Service
> Software or Service that you use
> Components that you add/integrate into your app
> Virtual Application Server > Handles Scale-Out
> Mostly Managed by Provider
> Virtual Servers > Similar to Virtualization
> Manage Everything Yourself
![Page 5: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/5.jpg)
Why Cloud? • Compelling Economics
– Lower CapEx – Cheaper handling of peak loads
• Flexibility and better productivity for development – Self service portal – Much easier to set up environments
• Better Service – Redundancy across multiple data centers – Lower latency because of local data centers
![Page 6: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/6.jpg)
So: What Shall I use? • IaaS: Maximum control, but:
– Need to install infrastructure – Need to install application – How do you do application updates?
• PaaS: Much easier to handle – …but often less flexible – Monitoring, deployment etc built in – Probably the better choice
![Page 7: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/7.jpg)
Google App Engine • Non relation data store (NoSQL) • (Limited) JPA interface to data store • Available Java classes limited (White List) • No control over web server, operating system • Strategic partnership SpringSource / Google
• Spring works
![Page 8: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/8.jpg)
Amazon Beanstalk • Tomcat + OpenJDK + Linux on EC2 • + Monitoring, Versioning, Events… • Auto Scaling • Can add MySQL (RDS) with backup etc
• Sample application uses Spring
![Page 9: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/9.jpg)
Cloud Bees • Focus on DEV@Cloud
– Continuous Integration – Maven Repository
• RUN@Cloud: Tomcat+OpenJDK + Linux on EC2
• Announce beta for Private Cloud • MySQL also available • Very limited scaling / SLAs
• Spring works
![Page 10: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/10.jpg)
VMware Cloud Foundry • Tomcat on VMware Public Cloud or Micro
Cloud (i.e. laptop) or EC2 or … • Platform is Open Source • Can add MySQL, Redis, MongoDB • Services injected into application • Framework support needed • Spring: A MySQL DataSource is rewired to a
MySQL service
![Page 11: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/11.jpg)
Cloud Foundry Spring Integration
• Cloud namespace: bind to Cloud Foundry services
• Works with Spring 3.0.5
• Note: No need for environment specific config • App can run unchanged in test / dev /
production Cloud Foundry environments
<cloud:data-source id="dataSource"/><cloud:mongo id="mongo"/><cloud:redis-connection-factory id="redisConnectionFactory"/>
![Page 12: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/12.jpg)
PaaS Conclusion • Spring (+ Tomcat) own the Cloud • Also predominant non-Cloud Enterprise
platform • Lightweight – more important for Cloud
– Pay any consumed resource – PaaS: Need operations / monitoring / deployment – Easier for a simple environment
• Spring has always been about portability • Not just Java EE / Tomcat / … - also Cloud
![Page 13: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/13.jpg)
Full Java EE Stack? • Spring & Tomcat:
The Enterprise & Cloud Java dream team • Of course can also use other Java EE APIs
on Tomcat
• There is no offering for a full Java EE PaaS stack
• i.e. including EJB, JMS, JTA …
![Page 14: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/14.jpg)
My First Cloud App
Tomcat
Catalog Order
RDBMS
![Page 15: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/15.jpg)
My First Cloud App: Platform • Programming model
Same as for Enterprise Java Apps • E.g. JSF + Spring + JPA … • Run on IaaS: Need to install infrastructure
– Must be automated
• Google App Engine – JSF probably won’t work – Spring and GWT will – No RDBMS - but NoSQL with (limited) JPA
![Page 16: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/16.jpg)
My First Cloud App: Platform • Amazon Beanstalk
Cloud Bees Cloud Foundry – Environment you are used to: Tomcat + MySQL – Cloud Foundry: Optional cloud namespace in the
configuration
• For a start a normal Spring application is OK • What are the limits?
![Page 17: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/17.jpg)
How Is Cloud Different? • Need to be able to add new servers • Provided for by PaaS • New servers must be able to handle load
instantly (warm cache)
• Prefer Scale Out instead of Scale Up • i.e. add new servers instead of bigger ones • Usually not an option with RDBMS • Scale up is possible but limited
![Page 18: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/18.jpg)
How Is Cloud Different? • Complex networks setup • Nodes might be unavailable • Might want to run cluster across data center
for availability • Server might and will fail • Very different from normal servers
![Page 19: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/19.jpg)
How Is Cloud Different?
![Page 20: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/20.jpg)
![Page 21: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/21.jpg)
So How Is Cloud Different? • No operations department to blame • Unreliable and potentially slow network
• How can you even dare to build reliable systems that way?
• Amazon and Google accomplish that • Will happen in Enterprises as well • Much more efficient in operations /
development
![Page 22: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/22.jpg)
So How Is Cloud Different? • No operations department to deal with – just
a portal!
• Multiple world-wide distributed data centers available to you! – Redundancy – Low latency from any place
• New virtual computers spun up in minutes! • Need a larger machine – just reboot!
![Page 23: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/23.jpg)
Cloud is Just Another Trade Off • How can applications be successfully created
in this environment?
![Page 24: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/24.jpg)
CAP Theorem • C: Consistency: All nodes see the same data • A: Availability: Node failure does not prevent
survivors from operating • P: Partition Tolerance: System works even
though message are lost
• Choose any two • No P in the Cloud? • So A or C?
![Page 25: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/25.jpg)
Consistency
Partition Tolerance
Availability
RDBMS 2 Phase Commit
DNS Replication
Quorum
![Page 26: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/26.jpg)
My First Cloud App
Tomcat
Catalog Order
RDBMS
Actually works Now let’s scale it up …and enter the globalized world
![Page 27: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/27.jpg)
Scaling My First Cloud App
Tomcat
Catalog Order
RDBMS RDBMS RDBMS
Replication? Across data centers? Write performance? Reliable?
Fast?
Global business More customers
Catalog used a lot more than Order
![Page 28: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/28.jpg)
Scaling My First Cloud App • IaaS
– Can use other regions and scale datastore – Limits of technology (RDBMS) still apply – Need to installation / configuration it yourself
• Google App Engine – Datastore scales well – Global data centers?
• Amazon Beanstalk – Turn key MySQL with replication (RDS) – …but of you can’t change the limits of RDBMS – Beanstalk only in US East at the moment
![Page 29: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/29.jpg)
Scaling My First Cloud App • Cloud Bees
– Data center only in the US – MySQL installation very limited – Can use Amazon RDS
• Cloud Foundry – Data centers only in the US – MySQL limited
• You will need to do more yourself e.g. on EC2 • Less support by the PaaS
![Page 30: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/30.jpg)
Tomcat
My Second Cloud Application
Tomcat
Catalog Catalog
Updates as messages Will be eventually delivered AP, but no C
Catalog separated Because of load
![Page 31: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/31.jpg)
My Second Cloud Application • Parts of application separated because of scaling
scheme • Introduce “Eventual Consistency”
– Either using NoSQL (e.g. CouchDB) – …or using messaging – Might consider in memory or cache (Redis, memcached,
GemFire) • RabbitMQ is the predominant approach for messaging
in the cloud – NASA’s nebula project – #1 on EC2 – Support in Cloud Foundry planned
• More messaging: Amazon SNS, SQS …
![Page 32: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/32.jpg)
Tomcat
My Second Cloud Application
Tomcat
Order Order
Orders are sent as messages Will eventually be sent to the backend Will eventually be handled by the backend
![Page 33: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/33.jpg)
2nd Cloud App: Programming Model
• Very different from a normal Enterprise Java three tier application
• Not so different from a portal • No one global database • Focus on messaging
• Need support for RabbitMQ / AMQP • I.e. Spring AMQP (see other talk) • Programming model very much like Spring JMS • Can create message driven POJOs
![Page 34: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/34.jpg)
2nd Cloud App: Programming Model
• Need NoSQL / Caching / Data Fabric • See Spring Data talk • Spring supports many relational technologies
– iBATIS, Hibernate, JPA … – E.g. common exception – Uniform API approach – Still specific API for each technology
• These abstractions are flexible • Can be used for NoSQL as well!
![Page 35: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/35.jpg)
• Catalog browsing statistics from log files • i.e. how many customer looked at X? • Sounds like a batch • File in, statistics out • With Spring Batch
• But: Globally distributed data • A lot of data • Some systems might not be online • How do you deal with that?
Another Cloud Challenges
![Page 36: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/36.jpg)
Spring Batch? • Spring Batch can be used to run batches • I.e. Jobs with steps • But:
– How do you deal with the distribution? – No central place with all the data – Do you prefer incomplete data or no data at all?
• Need something different.
![Page 37: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/37.jpg)
Map / Reduce • Map: Apply a function to all data
– Emit (item name, 1) for each log file line • Master sorts by item name • Reduce: Add all (item name, 1) to the total
score
• Map can be done on any node
• Master collects data Map Map
Reduce
![Page 38: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/38.jpg)
Map / Reduce Benefits • Data can stay on workers • Can done in parallel on many machines • Prefer answer on available data over no
answer at all • Can deal with redundant storage • But:
– Lot of network communication – More work in total
![Page 39: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/39.jpg)
Spring Hadoop • Hadoop is a complete solution for Map/Reduce • HDFS Filesystem • HBase Database • Hive for Data Warehousing / ad hoc queries
• Spring Hadoop adds templates and POJO based model
• https://github.com/springsource/spring-hadoop
![Page 40: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/40.jpg)
And What About Java EE 7? • Cloud is one of topics for Java EE 7 • Theme: Multi-Tenant / Isolation of customers • New role: PaaS Administrator • Additional security • QoS • Application Metadata • Caching will become more important and will
be covered by Java EE
![Page 41: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/41.jpg)
The Cloud Challenge Java EE Does Not Solve
• JTA = 2PC = CA, not P • JPA / JDBC = CA, not P • Will you use that in the Cloud?
• NoSQL?
• RabbitMQ?
![Page 42: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/42.jpg)
Java EE 7 & Cloud • Multi tenant: Just one way to isolate users • Can also use virtual machines, individual servers
etc • Multi tenant good for lots of small applications • Has been used for SaaS systems
• Tomcat and Servlets dominate the Cloud market • When will certified Java EE 7 servers be
available? • Who will provide a Cloud based on Java EE 7?
![Page 43: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/43.jpg)
Conclusion • IaaS is very flexible • PaaS makes deployment, monitoring and operations
easier • All Java PaaS support Spring • Demanding Cloud applications need
– AMQP messaging – NoSQL / Caching – Map/Reduce
• Spring’s general abstractions can be extended to support this
• Concepts you are used to!
• Java EE is stuck with “traditional” enterprise systems
![Page 44: Spring in the Cloud](https://reader037.fdocuments.us/reader037/viewer/2022102905/55d4b566bb61eb952c8b457d/html5/thumbnails/44.jpg)
www.AAAjobs.de
Wir suchen Sie als
Software-Architekt (m/w) Projektleiter (m/w) Senior Software Engineer (m/w)
Kommen Sie zum Stand und gewinnen Sie ein iPad 2!