İleri Seviyede Oracle Ön Bellek Mekanizması (Oracle Coherence) Ahmet Fuat SUNGUR afsungur@gmail.com @afsungur 11.10.2012 – Bahçeşehir University Who am i Y.T.U – Computer Engineering I.T.U – Computer Engineering, not completed Since 2008, Turkcell Technology afsungur@gmail.com @afsungur Agenda What is the cache and buffer? Why we use caches in designing programming? Oracle Coherence Features Demos Final Buffer Memory A buffer is a region of a physical memory storage used to temporarily hold data while it is being moved from one place to another. It is a temporary memory location that is traditionally used because CPU instructions cannot directly address data stored in peripheral devices. Caching A cache is a component that transparently stores data so that future requests for that data can be served faster. Caching CPU Cache TLB ( Translation Lookaside Buffer ) Disk Cache Web Cache DNS Cache Cache in Programming request response EMP_ID NAME TEL_NO GENDER 1 Ahmet 531232 M 3 Hasan 855412 M r e s p o n s e DB r e q u e s t EMP_ID NAME TEL_NO EMAIL ADDRESS GENDER 1 Ahmet 531232 afsungur@gmail.com Bahçelievler/İst M 2 Aysel 895244 aysel@hotmail.com Çankaya/Ankara F 3 Hasan 855412 hasan@outlook.com Levent/İstanbul M 4 Veli 789621 veli@msn.com Sarıyer/ İstanbul M Oracle Coherence A variety of caching strategies Reporting and administrator support via JMX and associated tools Rich language support via Coherence*Extend Has no single point of failure Automatically and transparently fails over and redistributes its clustered data managements services. Automatically scale up your application when a server added What is Coherence Cluster Node A Coherence Cluster node Sometimes referred to as a member or cluster member Is a java process Joins a cluster Is an instance of Coherence server Can contain data, run processing and serve events Is often defined by a cache configuration localstorage.enabled = true => node contains data JVM 1 PID : 5654 NODE 1 JVM 2 PID : 5655 NODE 2 JVM 3 PID : 5656 NODE 3 Clustering in Coherence Using a conference room model -Dtangosol.coherence.cluster=name Listening Discovery Working Groups and Private Conversation Death detection Failed Servers Failover Failback Coherence Cache Topology Examples Local Cache JVM Local Cache Replicated Cache JVM Replicated Cache JVM Replicated Cache JVM Replicated Cache Coherence Cache Topology Examples Partitioned Cache ( Distributed Cache ) JVM JVM JVM Partitioned Cache Near Cache JVM Local Cache JVM JVM Partitioned Cache Replicated Cache Animation CUST_ID NAME TEL_NO 1 Ahmet Sungur 5301112233 2 Ayşe Öz 5321112244 3 Mehmet Akar 5341234561 Seamlessly get all cache data and put into in its own cache Add a customer 1,2 3 1,2 3 1,2 3 Partitoned Cache Animation CUST_ID NAME TEL_NO 1 Ahmet Sungur 5301112233 2 Ayşe Öz 5321112244 3 Mehmet Akar 5341234561 Add a customer 3 1 2 Near Cache Animation returns 1 from requests 1 returns 2 to app from Front cache front cache From front cache 23 4 1 2 no need to access back cache 1 requests 2 from Front cache 2 returns 2 from it’s need to access back cache and back cache write it to front cache 3 4 Generally, Local Cache is used for front cache, because of ~0 cost Generally, Partitioned Cache is used for back cache, because of accessing much more data. Near Cache Animation Updates 2 to Front cache 23 4 1 2 1 2 3 4 Near Cache invalidation strategies Listen None Listen Present Listen All Listen Auto Failover When data source is involved Read-Through Write-Through Write-Behind Refresh-Ahead Caching Read Through Caching Write Through Caching Write-Behind Caching Improves application performance Reduces database load Insulated from database failures Linear Scalibility Refresh-Ahead Two parameters Expiration time Refresh-ahead factor Expiration time:60 seconds Refresh Ahead factor :0.5 Request «1» @13:45:10 48-10>60*05, So no need to reload Request «2» @13:45:15 CUST_ID NAME TEL_NO EXPIRATI ON_TIME 1 Ahmet Sungur 5301112233 13:45:48 2 Ayşe Öz 5321112244 13:45:24 Got fresh object from db ( obj 2 ) 13:46:15 24-15<60*05 So we need to reload Get object 2 from db put into the cache Database Event and Parallel Processing Coherence supports two background processing models Parallel Processing Events Map listeners which are called asynchronously after data changes Map triggers which are called synchronously before data changes Queries and Filters Coherence supports two query mechanism A filter mechanism, useful for events and event filters MapEventFilter AndFilter, OrFilter … A SQL-Like mechanism known as the Coherence Query Language useful for queries against caches SELECT result-set | * FROM cache-name WHERE conditional-expression Select * from customers where name like ‘%ap%’ Select max(price) from stocks where lastupdatedate Select avg(price) from stocks Insert, update, delete… Demo Time Oracle Virtual Box 4.1 Oracle Enterprise Linux OEPE ( Oracle Enterprise Package for Eclipse ) Oracle Coherence 3.7.1 Other Coherence Security Coherence Management Managing and monitoring via JMX Coherence Reporter Coherence*Extend Coherence*Web Summary