3. What is a Microservice?
In computing, microservices is a
software architecture style in which
complex applications are composed of
small, independent processes
communicating with each other using
language-agnostic APIs.
Wikipedia
4. Fallacies of Distributed Computing
1.The network is reliable.
2.Latency is zero.
3.Bandwidth is infinite.
4.The network is secure.
5.Topology doesn't change.
6.There is one administrator.
7.Transport cost is zero.
8.The network is homogeneous.
Wikipedia
6. Latency
Technology Latency Transfer Rate
DRAM 10s Nanos 120GB/s
SSD 0.1ms 600MB/s
Hard Disc 10ms 200MB/s
1Gb Ethernet Local :
50 micros
Lan Segment:
300 micros
Switch
4 ms
Within UK
30 ms
UK <-> USA
100ms
25 – 30 MB/s
10. What is Payara Micro
• Small Footprint Java EE Runtime
• Supports Java EE Web Profile
• Embeds JCache Support
• Auto clusters using Hazelcast
• Fully Embeddable API
• Later today compare with SpringBoot, WildFly
Swarm
java –jar payara-micro.jar –deploy test.war
13. JCACHE
• Standard Java API for Caching
• JSR107
• API and CDI binding
• Supported by Many Cache Providers
• Hazelcast, EhCache, Coherence, Infinispan, Apache Ignite
• Built in to Payara Server
• Uses Hazelcast
15. Core Concepts
• CachingProvider
• Retrieves and closes Cache Managers
• CacheManager
• Creates and destroys caches
• Cache
• Contains Objects in Key Value Pairs
16. Magic Behind @CacheResult
• CDI Interceptor
• Obtains CacheManager from CachingProvider
• Creates Cache Name (Based on Method)
• Looks up Cache in CacheManager
• Takes Method Parameter Values and creates Cache Key
• Does Cache.get before invoking method
• If not in cache invokes method and does cache.put on
the result.
18. Further CDI
• @CacheResult
• Caches the result of a method call
• @CachePut
• Cache a specific method parameter
• @CacheRemove
• Removes a cache entry based on parameters
• @CacheRemoveAll
• Removes all entries in the cache
24. Summary
• Use caching to defeat latency
• JCache standard api for caches
• Using JCache on Payara is simple
• Jcache, Hazelcast and CDI are built in
• Build micro-services with distributed caching on Payara
Micro
• Hazelcast Provides Performance, Resilience and
Scalability
• JCache also provides Data Grid capabilities like compute
and events.
25. More Info
• https://jcp.org/en/jsr/detail?id=107
• JSR 107 Jcache specification
• http://www.payara.fish
• Payara information and downloads
• http://www.hazelcast.com
• Get Hazelcast
• https://github.com/smillidge/JDays2016
• Code for this talk
• https://github.com/payara/Payara-Examples/tree/master/rest-
examples/rest-jcache
• Example key value store
• https://github.com/payara/Payara-Examples/tree/master/JCache-
Examples
• Further JCache on Payara Examples
Moves the processing the the data not the other way around!
Much more efficient and the processor will likely have a small amount of data associated with it whereas the cache size may be very large!
Used for Chat
Could be used for new trades for a trader or bids or offers on a security
Asynchronous notification
Management