ACCS provides the perfect cloud service to develop microservices on! In this presentation I'll demonstrate some of recent the highlights for developers such as Python support, integration options with the Event Hub and I'll go into detail for using the Application Caches to increase performance. Spring Boot will be used extensively in this presentation. After this presentation you will have a better understanding of the options provided by ACCS to create microservices quick and easily.
4. MICROSERVICES ON
APPLICATION CONTAINER CLOUD SERVICE
MICROSERVICE
ARCHITECTURE
TWELVE FACTOR
APPLICATION
APPLICATION CONTAINER
CLOUD SERVICE
SPRING BOOT DOCUMENTING YOUR API
USING THE ACCS CACHE
WITH THE ACCS JAVA SDK
DEPLOYING AND RUNNING
ON ACCS
6. MICROSERVICE ARCHITECTURE IN THE CLOUD
THE CHALLENGES ARE DIFFERENT FROM ON PREMISES
• Environment differs
Administration, connectivity
• DTAP environments
Local development / testing?
• Security
The entire world can access your services
• Scalability
7. TWELVE FACTOR APPLICATION
HOW
• Codebase
• One codebase tracked in revision control,
many deploys
• Dependencies
• Explicitly declare and isolate dependencies
• Config
• Store config in the environment
• Backing services
• Treat backing services as attached
resources
• Build, release, run
• Strictly separate build and run stages
• Processes
• Execute the app as one or more stateless
processes
8. TWELVE FACTOR APPLICATION
HOW
• Port binding
• Export services via port binding
• Concurrency
• Scale out via the process model
• Disposability
• Maximize robustness with fast startup and
graceful shutdown
• Dev/prod parity
• Keep environments as similar as possible
• Logs
• Treat logs as event streams
• Admin processes
• Run admin/management tasks as one-off
processes
9. MICROSERVICE ARCHITECTURE IN THE CLOUD
12 FACTOR APPLICATION: A METHODOLOGY FOR BUILDING SAAS APPS
Application Container
Cloud Service
10. APPLICATION CONTAINER CLOUD SERVICE
• On demand scale out/in.
Adding/Removing instances
• On demand scale up/down.
Adding/Removing memory per instance
• Automatic load balancer configuration
• One click patching
• Easy to configure service bindings
13. SPRING BOOT
BUT WHY?
• Popular
Java is very popular!
#1 TIOBE index
#3 on Stackoverflow and Github
Netflix uses it
• Performant
Spring Boot outperforms JavaScript on Node if you
do the same things
Like validation, authentication, formatting
• Rich in features
Uses Spring but with many shortcuts.
Spring provides a lot of out of the box functionality
such as integration and security
• Fast to develop
Spring Boot makes it easy to create stand-alone,
production-grade Spring based Applications that
you can "just run".
15. SPRING BOOT
DOCUMENTATION
• Contract first (design first)
Generate Spring Boot code using Smartbear Swaggerhub
• You can even generate code from your Maven build using swagger-codegen
https://rphgoossens.wordpress.com/2018/02/10/swagger-generation-automation-or-creating-the-bottling-line/
https://swaggerhub.com/blog/api-design/design-first-or-code-first-api-development/
23. 1 2
SPRING BOOT ON DOCKER
Create a Dockerfile Use dockerfile-maven-plugin
In your pom.xml
24. SPRING BOOT
ON DOCKER
• Get base images from public registries
• OpenJDK on Alpine Linux
https://spring.io/guides/gs/spring-boot-docker/
• Oracle JDK on Oracle Linux
+
+
http://javaoraclesoa.blogspot.com/2018/03/running-spring-boot-in-docker-container.html
25. SPRING BOOT
ON DOCKER
mvn package dockerfile:build
docker run -p 8081:8081 maartensmeets/accs-cache-sample:latest
https://github.com/spotify/dockerfile-maven
Dockerfile
26. SPRING BOOT
ON DOCKER: DIFFERENT FROM ACCS
• There is no local ACCS environment
You cannot test deployment locally
• ACCS bindings cannot be tested locally
LocalSessionProvider is available for the cache
27. 1 2
BUILD A ZIP TO DEPLOY TO ACCS
What should be in the ZIP How do you create those files
28. SPRING BOOT ON ACCS
BUILD A DEPLOYABLE
ACCS Deployable ZIP
manifest.json
deployment.json
uberJAR.jar
Create with the
maven-assembly-plugin
Create with the
spring-boot-maven-plugin
29. SPRING BOOT ON ACCS
BUILD A DEPLOYABLE
Describes what should go in the ZIP file for ACCS
JAR + manifest.json + deployment.json
Creates a Spring Boot über JAR with
dependencies which ‘just runs’
34. USING THE APPLICATION CACHE
Application Cache 1
Customers
Shopping
carts
Inventory
Application Cache 2
Customers
Shopping
carts
Inventory
Java SE
App 1
Java SE
App 1
Node JS
App 1
Java SE
App 3
35. USING THE APPLICATION CACHE
HOW FAST IS IT?
• Environment
• ACCS: 1 OCPU, 1 Gb
• Cache: 2Gb Basic
• Tested with GET request, small payload
• Average response time for 3500 requests, 20 threads, 60s
• End to end: 236ms (no significant difference REST / GRPC)
• GRPC: 5ms (1ms - 40ms)
• REST: 3ms (0ms - 70ms)
• Local: 0ms
39. USING THE APPLICATION CACHE
DEPENDENCY CHALLENGES
• Java 9 lacks some libraries from previous SDK’s
Additional dependencies needed
• Additional GRPC libraries are required
40. USING THE APPLICATION CACHE
IN SPRING BOOT
Entity
Repository
Controller
Exposes resources / presentation
E.g. RestController
Handles connectivity / persistence / DAO
The resource
Service Service / operation
Implement cache
code
Implement logic to
use the cache or
another repository
41. USING THE APPLICATION CACHE
IN SPRING BOOT
• Oracle provides an open source SDK
• Java Client Caching SDK for Oracle Application Container Cloud Service
https://github.com/oracle/accs-caching-java-sdk
42. USING THE APPLICATION CACHE
IN SPRING BOOT
CacheRepositoryDbRepository
Service
Cache
SerializerLoader
43. USING THE APPLICATION CACHE
IN SPRING BOOT
• Create a SessionProvider
• Use the SessionProvider to create a Session
• Use the Session to get a Cache object
• Use the Cache object to access the cache
Can be a Local or Remote.
Remote requires an URL
The session can be REST
or gRPC (HTTP/2) based
Allows you to configure
• Expiry
Determines validity of cached objects
• Loader
This is called when there is no cache hit
• Serializer
Objects need to be serialized to be put in the cache
44. APPLICATION CONTAINER CLOUD SERVICE
GOOD TO KNOW
• Deployment
Sometimes old deployment ZIP files are used
Recommendation: script removing files from storage cloud
• Debugging
Can be time-consuming. A single deployment can take minutes.
• The Java Client SDK
does not provide support for a findAll method
45. APPLICATION CACHE
GOOD TO KNOW
• Expiry
Has issues with the LocalSessionProvider
Tip: set it to never expire
• Environment differences
Working locally is no guarantee for working in the cloud!
• Dependencies / performance
Test with both GRPC and REST. REST could be faster!
You can’t remove a cache which has bindings to applications
• Availability
During patches, updating bindings -> implement retries or error handling
46. WANT TO LEARN MORE?
• Java
• Complete working sample Spring Boot on ACCS with Application Cache
https://github.com/MaartenSmeets/springboot
• A sample of using the cache. Application is Jersey based (no Spring)
https://github.com/abhirockzz/app-container-cloud-cache-example
• Python
• A minimal sample of using Python on ACCS
https://github.com/MaartenSmeets/pythonscripts/tree/master/microservice-accs/minimal-sample
• An elaborate sample of using Python on ACCS
https://dzone.com/articles/deploy-a-python-application-to-oracle-application
Notes de l'éditeur
Smooth transition from dev to prod
Easy integration with underlying platform
ACCS is more GUI based and Heroku is more commandline / configuration file based. Deployment to Heroku is much faster!
Why is this my favorite cloud service?
Clean contract, language independent
Example Java SE, Spring Boot
https://octoverse.github.com/
https://insights.stackoverflow.com/survey/2017
Performance: https://www.linkedin.com/pulse/nodejs-vs-java-which-faster-apis-owen-rubel
Na application server required. Ideal to just run a Jar in a Docker container
Netflix uses it
Spring is a solid framework
a large codebase
many contributors
Spring Boot makes using Spring easy by taking an opinionated viewMinimal configuration required for 80% of the use cases
Designed to get you up and running as quickly as possible.
Does not require an application server (has embedded Tomcat)
You just need a JVM to run
https://swaggerhub.com/blog/api-design/design-first-or-code-first-api-development/
Internal API’s -> code first
External API’s -> design first. Better communication and better experience
Useful for quick stub generation
Easy to import Swagger documentation in a tool like Postman
Why? To test locally
First is easy. No need to create accounts, works out of the box
Second requires an account on store.docker.com and requires you to accept a license
ACCS is OEL7
Why? To test locally
https://github.com/oracle/docker-images/tree/master/OracleJava
Add Dockerfile. Specifies container base
The local environment differs. No loadbalancer, no internal and external hostnames
Cache can be unittested
between technologically diverse stateless serviceslike session data
Multiple apps can use the same application cache. A single app can use a single application cache
Application cache runs on Coherence
Useful for sharing session state across apps or app nodes.
The cache name should not contain characters like ‘-’This will cause the creation to fail (specifically LBaaS configuration)
Or in the deployment.json file or by manually adding a binding
This does two things
Ensuring there is secure network connectivity to the cache
Make connection information to the cache available as parameters inside the Docker env
Also allows local development
Get requests directly to the cache
Put requests to both
Oracle provides a client SDK: https://blogs.oracle.com/developers/introducing-application-cache-client-java-sdk-for-oracle-cloud which has been open sourced: https://github.com/oracle/accs-caching-java-sdk
Also see https://community.oracle.com/community/oracle-cloud/oracle-cloud-developer-solutions/blog/2017/06/06/build-oracle-app-container-cloud-cache-based-application-cicd-using-oracle-developer-cloud