Cloud Platforms for Java

1,818 views
1,686 views

Published on

A presentation on cloud platforms for Java by 3Pillar Global Java Tech Lead Florin Jurcovici.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,818
On SlideShare
0
From Embeds
0
Number of Embeds
198
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cloud Platforms for Java

  1. 1. Cloud Platforms for Java
  2. 2. WHAT I’LL LOOK AT? • What needs to be managed • How deployment works • What services are available • Pluses and minuses (as perceived by me) © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 2
  3. 3. GOOGLE APP ENGINE - OVERVIEW • Truly a platform • You don’t manage machines • You just upload the binaries and GAE runs them • Large variety of services: • JDO & JPA interfaces to data, MySQL in the cloud, • Memcache, GAE datastore • URL fetch API, Java Mail API • Images service – generate/process images • Oauth (experimental), Google accounts • Cron jobs © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 3
  4. 4. GOOGLE APP ENGINE - TOOLING • GAE SDK • Maven and ant build supported • Local app engine development server • Command line tool for interaction with an app • IDE Support • Best supported is Eclipse • NetBeans plugin • IntelliJ Idea – support built into the ultimate edition © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 4
  5. 5. GOOGLE APP ENGINE - RUN • Test/debug: hit run/debug in Eclipse • Console output says where the app runs locally • Run local outside IDE – command line: • dev_appserver.sh helloworld.jar • Upload and run in the cloud: • appcfg.sh update helloworld.jar © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 5
  6. 6. GOOGLE APP ENGINE - MINUSES • No direct filesystem access • No direct socket access • Must be quick (but there are backends) • request handling must finish within seconds, or it gets you killed • No signed jars • There's a jre class whitelist • Use of any jre class not in the list gets you killed • Not really service-oriented • No REST/SOAP APIs, or at least not published as such • You inherit and use factories a lot © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 6
  7. 7. GOOGLE APP ENGINE - PLUSES • Indexing of the datastore, much nicer than a plain file system • Auto-generated but can be hand-tuned • Built-in logging • Logs can be downloaded • Routing by domain header in request • One app can serve multiple domains • Backends = special apps • 60 seconds cap per request, more mem & CPU • Created/destroyed on demand • Many services = APIs available in-app • App identity, logs, images, oauth, search, URL fetch, Java mail, many others • Many are experimental and evolving © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 7
  8. 8. GOOGLE APP ENGINE – HELLO WORLD // from the SDK demos – no difference to tomcat package org.example; import java.io.IOException; import javax.servlet.http.*; public class HelloAppEngineServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); resp.getWriter().println("Hello, world"); } } © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 8
  9. 9. GOOGLE APP ENGINE - BACKENDS <!-- from the demos – backends.xml --> <!-- putting a backends.xml in WEB-INF starts your app as a backend --> <backends> <backend name="small"> <class>B1</class> <options> <public>true</public> </options> </backend> <backend name="medium"> <class>B2</class> <instances>3</instances> <options> <fail-fast>true</fail-fast> </options> </backend> <backend name="big"> <class>B4</class> <options> <dynamic>true</dynamic> </options> </backend> </backends> © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 9
  10. 10. GOOGLE APP ENGINE – DATASTORE • Datastore is hierarchies of typed entities /Person:grandpa / Person:dad / Person:son • When creating an entity, you can specify a kind, a key and an ancestor • Entities can have additional properties – indexed & unindexed • Can query by keys, ancestors or indexed props © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 10
  11. 11. GOOGLE APP ENGINE - DATASTORE Entity entity = new Entity("entityType"); entity.setProperty("mykey", mykey); entity.setUnindexedProperty("value", value); datastore = DatastoreServiceFactory.getDatastoreService(); Key key = datastore.put(entity); Query query = new Query("entityType"); PreparedQuery prepared = datastore.prepare(query) List<Entity> entities = prepared.asList(FetchOptions.Builder.withLimit(100)); Entity retrieved = datastore.get(key); datastore.delete(retrieved); © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 11
  12. 12. AMAZON WEB SERVICES - OVERVIEW • Most renowned service is EC – Elastic cloud • The Java app platform is actually Elastic Beanstalk • Servlet-based, like GAE • More languages supported than GAE • Big bonus: services are not coupled to other services, like for GAE © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 12
  13. 13. AMAZON WEB SERVICES - TOOLING • SDK • Bunch of libs, no binaries to run locally • Simple and easy to set up projects with maven or ant • Eclipse plugin • One-click deploy • Netbeans built-in support • From v7.2 onwards • IntelliJ Idea • Extensive support for managing AWS services © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 13
  14. 14. AMAZON WEB SERVICES - RUN • No local dev server • None needed, because you can debug locally, sincer AWS services are callable from anywhere, not just apps running on Beanstalk or EC2 • Beanstalk server is tomcat • One click publishing of apps in Eclipse • From the AWS console • Just upload the war file © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 14
  15. 15. AMAZON WEB SERVICES - PLUSES • Full control • Full Java platform • Although no JEE, you can install your own on EC2, but than you don't use beanstalk anymore • Easier migration into the cloud • Gobs of services, truly service oriented • S3 more like a local file system • Anything you like via EC2 instances • Big plus: asymmetric key crypto for access control © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 15
  16. 16. AMAZON WEB SERVICES - MINUSES • Not many, no really bad things • Default project in Eclipse is uses jsp instead of a servlet • Deployment to tomcat only • Amazon's initial offering (EC2) shows through • Every app instance is started as a new EC2 instance • Monitoring happens at the machine level • Only infrastructure scalability is addressed • there aren't built-in, Beanstalk-prov © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 16
  17. 17. AMAZON WEB SERVICES – S3 // files are kept in buckets AmazonS3 s3 = new AmazonS3Client( new new BasicAWSCredentials( "key", "secret")); s3.createBucket(“myBucket”); s3.putObject( new PutObjectRequest( “myBucket”, “fileName”, someFile)); S3Object object = s3.getObject( new GetObjectRequest(“myBucket”, “fileName”)); s3.deleteObject(“myBucket”, “fileName”); © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 17
  18. 18. HEROKU - OVERVIEW • Runs on Amazon EC2 • a PaaS on top of IaaS from another provider • Dynos and slugs • Dynos are sort of a VM, but based on cgroups • Slugs are your apps packaged for a dyno • Many languages, in its latest incarnation: • Ruby, Java, Python, Scala, JavaScript, Clojure • Thought to be extremely beginner-friendly © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 18
  19. 19. HEROKU - TOOLING • Provides a toolbelt • On Ubuntu: wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh • Toolbelt contents: • Local app runner – not local server • CLI for uploading and updating apps • GIT interface -commit to git updates your running app • Easy start with Java • Tons of samples on github.com/heroku • Sources of part of heroku itself also on github © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 19
  20. 20. HEROKU - RUN • Toolbelt allows you to run profiles locally • No specific one-click run in Eclipse • You develop & deploy normal Java apps • => no need for extra test/debug fixtures © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 20
  21. 21. HEROKU – PLUSES & MINUSES • Heroku is different, that's all. • Dynos ~ like micro-/lightweight Vms • Better: no DNS/routing/security setup • Worse: a single open port => remote debugging sucks (but is possible w. special mechanisms) • No prepackaged app server in dynos • Must deploy your own runner with the app • Heroku's git repo provides runners (Jetty, tomcat7) © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 21
  22. 22. HEROKU – PLUSES & MINUSES • Git push updates the app • No intermediate on-platform tests possible • You can always use dev/test/prod branches • No dynamic scaling • But there are 3rd party services for this • Rich services environment • Really really really really rich – several dozen • Message queues, storage, monitoring, cron, memcache, mail, lo g & analysis, you name it • Debugging with add-on services locally is not ideal © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 22
  23. 23. HEROKU – POSTGRES ACCESS // use heroku-provided tools to provision databases URI dbUri = new URI(System.getenv("DATABASE_URL")); String username = dbUri.getUserInfo().split(":")[0]; String password = dbUri.getUserInfo().split(":")[1]; String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + "/" + dbUri.getPort(); Connection connection = DriverManager.getConnection(dbUrl, username, password); Statement stmt = connection.createStatement(); stmt.executeUpdate("DROP TABLE IF EXISTS ticks"); stmt.executeUpdate("CREATE TABLE ticks (tick timestamp)"); stmt.executeUpdate("INSERT INTO ticks VALUES (now())"); ResultSet rs = stmt.executeQuery("SELECT tick FROM ticks"); while (rs.next()) { System.out.println("Tick: " +rs.getTimestamp("tick")); } © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 23
  24. 24. HEROKU – MONGODB ACCESS // use heroku-provisioned tools to set up // MongoDB for your app MongoURI mongoURI = new MongoURI(System.getenv("MONGOHQ_URL")); DB db = mongoURI.connectDB(); db.authenticate( mongoURI.getUsername(), mongoURI.getPassword()); Set<String> colls = db.getCollectionNames(); System.out.println("Collections: " + colls.toString()); © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 24
  25. 25. WINDOWS AZURE - OVERVIEW I know, I'm surprised too. But don't get too excited. • There's a download available for Linux • Also a maven dependency • And an Eclipse plugin • It doesn't install on Linux • There's a CLI tool for Linux – using node © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 25
  26. 26. WINDOWS AZURE – GOOD AND BAD • VM-based • both Linux and Windows VMS are available • Small selection of add-ons • storage, some media services, CDN, mail, authentication, message queuing • Some more exotic services • Phone and address validation – worldwide • SMS, outgoing voice calls • You have to download, install and configure your own app server for Java-based web apps! © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 26
  27. 27. OPENSTACK - OVERVIEW • A first attempt at standardization • Nothing Java-specific here, no wrapper libs included • Primitive, compared to commercial offerings • The only standard service is storage • Storage is much like Amazon's S3 buckets • Fully RESTful APIs • API is standardized, but only for infrastructure-related operations (server creation, resource provisioning, reboot/re-image etc.) • OpenStack-based providers differentiate themselves via addon services • a few well-known names: HP, IBM, Canonical, Rackspace © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 27
  28. 28. CLOUDBEES - OVERVIEW • Really great, but not so well known • Standards-based, i.e. no jre restrictions a la GAE • Deploys to standards-based app servers (tomcat, jboss) • Rich integrated dev resources & services • built-in maven, svn, git repos • Sonar, Jenkins, SVN, GIT, Selenium in the cloud – all integrated • Rich autoscaling config built in © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 28
  29. 29. CLOUDBEES-RUN • One click run • Both local and deploy to the cloud • Does not really care what your app uses or does • CLI interface with the SDK • Interact with deployed apps • Maven plugin • goals for deploying to jenkins, to prod, or run locally © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 29
  30. 30. CLOUDBEES - TOOLING • Mainstream IDEs are supported • Eclipse, Netbeans, IntelliJ Idea • SDK • Many services/add-ons available • Relational and NoSQL databases • Message queues, search & indexing, log analysis • Private maven repo, wiki, Even an online IDE • Add-ons provided by other cloud users © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 30
  31. 31. JELASTIC - OVERVIEW • Very friendly console in browser • Point & click interface for deployments • Very simple • Not much there except create environments and • upload wars • No IDE plugins or local SDKs • Not many services • Nosql & relational databases • Virtual edicated servers © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 31
  32. 32. JELASTIC – PLUSES AND MINUSES • Feels like the VisualBasic of Java PaaS • Very few things to configure • Tomcat 6/7, Java 6/7, jetty, glassfish • No plain Java apps, no distinction between frontends and workers, no restrictions • Provides automatic scaling • Has data centers all over the civilized world + • Russia • Via partners © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 32
  33. 33. CONCLUSIONS • No standards yet • Emerging standards are rudimentary • OpenStack only has storage API specified • All platforms have significant shortcomings • Some platforms are not very service-oriented • Except AWS © Copyright 2014. 3Pillar | All rights reserved Strictly Confidential 33

×