Many organizations develop a combination of .NET and Java web and SOA applications. And, many of these applications need to share data with one another at run time. Often, they're all working on common business data that's stored in a database. Or, they might be dealing with continuous streams of data (for example, financial trading applications), and need to process it and share results with other applications, again all at run time.
Learn how to share data across multiple .NET to .NET and Java applications at runtime with the help of a distributed cache. This webinar covers:
1. .NET to .NET and Java application data sharing techniques
2. How distributed cache event notifications are used
3. How does Continuous Query help
4. Read-through and Write-through handlers
5. Caching strategies for different relationship types
6. Sharing data through database synchronization
7. High availability and scalability of distributed cache
1. www.alachisoft.com 1
Runtime Data Sharing
through
a Distributed Cache
Iqbal Khan
iqbal@alachisoft.com Ph: +1 (925) 236-2125
Alachisoft
.NET Performance Solutions
2. Alachisoft
NCache 2www.alachisoft.com
What is Runtime Data Sharing?
1. Server Apps Sharing Application Data Changes
Connected to a relational database
Data changed in the database and then shared
2. Server Apps Sharing Transient Data
This data is never stored in the database
Data is created at runtime, shared, and then destroyed
3. Server Apps Mix of .NET and Java
Data sharing may be between .NET and Java apps as well
3. Alachisoft
NCache 3www.alachisoft.com
Traditional Data Sharing Mechanisms
1. Relational Databases
Polling
Database notifications (SQL Server Query Notifications or Oracle Database
Change Notifications)
Performance and scalability issues
2. Message Queues
Message focused (not data focused)
Not intended for large data sets
Performance and scalability issues
3. Web Services or Remote Procedure Calls
Too complicated to develop and manage
Weakness: sender and receiver not decoupled
5. Alachisoft
NCache 5www.alachisoft.com
What is a Distributed Cache?
1. Cluster of cache servers
Pools their memory and CPU
2. Synchronizes cache across all servers
Updates immediately visible
3. Linearly scales transaction & memory capacity
Add servers to grow capacity
4. Replicates data for reliability
Without compromising performance & scalability
6. Alachisoft
NCache 6www.alachisoft.com
Distributed Cache Deployment Architecture
Filesystem Database Servers Mainframe
Distributed Cache Cluster
Windows 2008/2012 (64-bit)
Scale Horizontally
Memory pooled from all cache servers
Grid Computing Apps
(.NET/Java)
Web Services (.NET/Java) Server Apps (.NET/Java)Web Apps (.NET/Java)
7. Alachisoft
NCache 7www.alachisoft.com
Following Apps use Distributed Cache
1. Web Apps (.NET & Java)
To handle millions of users
2. Web Services (.NET & Java)
To handle millions of requests
3. Big Data Apps (.NET & Java)
To quickly process very large amounts of data thru distribution
4. Grid Computing Apps (.NET & Java)
To process very large computations thru distribution
5. Other Server Apps (.NET & Java)
To handle millions of requests
8. Alachisoft
NCache 8www.alachisoft.com
Three Common Uses of Distributed Cache
1. App Data Caching (for Database Bottlenecks)
In-memory cache faster than database
Cache linearly scalable which database is not
2. Reliable & Scalable Cache for ASP.NET Specific Data
ASP.NET Session State storage (most common)
ASP.NET View State cache
ASP.NET Output Cache provider
3. Scalable Runtime Data Sharing
Faster & more scalable than traditional message queues
Async data sharing in producer/consumer model
Powerful event notifications & continuous queries for app coordination
10. Alachisoft
NCache 10www.alachisoft.com
Event Notification Types for Data Sharing
1. Event Notifications between .NET and Java Apps
.NET and Java apps can send event notifications to each other
2. Data Focused Event Notifications
Whenever some data in the cache changes
3. Message Based Event Notifications
Publish/subscribe model
Message sent to one or more subscribers
11. Alachisoft
NCache 11www.alachisoft.com
.NET and Java App Event Notifications
1. Binary Portable Format
Data and messages in the cache can use Binary Portable Format
.NET objects can be read back as Java objects and vice versa
No XML based costly transformations needed
2. Events Notifications between .NET & Java Apps
.NET and Java apps can send event notifications to each other
12. Alachisoft
NCache 12www.alachisoft.com
Data Focused Event Notifications
1. Item Level Event Notifications
When specific cached items change (update/remove)
2. Group Level Event Notifications
When any data in a group changes (add/update/remove)
NCache 4.6 will have this feature
3. Cache Level Event Notifications
When any data in the cache changes (add/update/remove)
4. Continuous Query Event Notifications
When any data in a dataset in the cache changes (add/update/remove)
Dataset defined through SQL-like criteria
13. Alachisoft
NCache 13www.alachisoft.com
Item Level Event Notifications
// Define and item level event handler function
static void OnCacheDataModification (string key, CacheEventArg args)
{
switch(args.EventType)
{
case EventType.ItemRemoved:
break;
case EventType.ItemUpdated:
break;
}
}
// Register item level event handler function with a “key”
CacheDataNotificationCallback dataNotificationCallback
= new CacheDataNotificationCallback( OnCacheDataModification );
CacheEventDescriptor EventDescriptor
= cache.RegisterCacheNotification (key, dataNotificationCallback,
EventType.ItemRemoved | EventType.ItemUpdated,
EventDataFilter.DataWithMetadata);
14. Alachisoft
NCache 14www.alachisoft.com
Cache Level Event Notifications
// Define the event handler function
static void OnCacheDataModification (string key, CacheEventArg args)
{
switch(args.EventType)
{
case EventType.ItemAdded:
break;
case EventType.ItemRemoved:
break;
case EventType.ItemUpdated:
break;
}
}
// Register event handler function
CacheDataNotificationCallback dataNotificationCallback
= new CacheDataNotificationCallback ( OnCacheDataModification );
CacheEventDescriptor EventDescriptor = cache.RegisterCacheNotification (
dataNotificationCallback,
EventType.ItemAdded |
EventType.ItemRemoved |
EventType.ItemUpdated,
EventDataFilter.DataWithMetadata );
15. Alachisoft
NCache 15www.alachisoft.com
Continuous Query Event Notifications
string queryStr = "Select ClassLibrary.Product WHERE this.supplier = ?";
Hashtable values = new Hashtable();
values.Add("supplier", "Carlos Diaz");
ContinuousQuery cq = new ContinuousQuery(queryStr, values);
cq.RegisterNotification (
new QueryDataNotificationCallback (ItemAddedCallBack),
EventType.ItemAdded, EventDataFilter.None );
cq.RegisterNotification (
new QueryDataNotificationCallback(QueryItemCallBack),
EventType.ItemUpdated | EventType.ItemRemoved , EventDataFilter.None);
cq.RegisterClearNotification (
new ContinuousQueryClearCallback(CacheClear));
cache.RegisterCQ ( cq );
16. Alachisoft
NCache 16www.alachisoft.com
Message Based Event Notifications
1. App Generated Custom Event Notifications
Publish/subscribe model
App fires a notification into cache cluster, other apps receive it
2. Topic Based Event Notifications
Publish/subscribe model
Publisher sends a message against a topic to multiple subscribers
NCache 4.6 will have this feature
3. Queue Based Event Notifications
Publish/subscribe model
Publisher sends a message to any one subscriber through cache cluster
NCache 4.6 will have this feature
17. Alachisoft
NCache 17www.alachisoft.com
App Generated Event Notifications
// Define a callback function
void CacheCustomEvent(object eventId, object data) { }
Product product = new Product();
// Registering custom event callback function
cache.CustomEvent += new CustomEventCallback(CacheCustomEvent);
//Raise custom event when needed
cache.RaiseCustomEvent("custom event id", product);
20. Alachisoft
NCache 20www.alachisoft.com
High Availability (100% Uptime)
Dynamic Cache Cluster
Cache Cluster
NCache Srv
Add
Server
At
Runtime
Remove
Server
At
Runtime
NCache Srv NCache Srv
Remote Clients (Web/App Servers) TCP based Cache Cluster
Does not use Windows Clustering
Peer to peer architecture
No single point of failure
Add/remove servers at runtime
Without stopping cache or your app
Data adjusted automatically based
on caching topology
Hot Apply config changes
Change config properties while
cache is running
21. Alachisoft
NCache 21www.alachisoft.com
High Availability (100% Uptime)
Dynamic Configuration
Cluster membership info
Propagate to clients at runtime
Cache topology info
Propagate to clients at runtime
Connection strategy at runtime
Connection failover
Clients auto-connect to other servers
Dynamic Cache Cluster
NCache Srv
Remote Clients (Web/App Servers)
NCache SrvNCache Srv
Cluster
Membership Info
Cache
Topology Info
22. Alachisoft
NCache 22www.alachisoft.com
Caching Topologies
Mirrored Cache (2-node active/passive)
Server 1 Server 2
Mirrored Cache
1 2
3 4
5 6
Active
1 2
3 4
5 6
Passive
(Backup)
Async Backup
Remote Clients (Web/App Servers)
All clients connect to active node
Passive node becomes active if
active node goes down. Clients
also automatically connect to new
active node
Mirroring to passive node done
asynchronously
Recommended use:
Up to 10 app servers
2 cache server cluster
23. Alachisoft
NCache 23www.alachisoft.com
Caching Topologies
Replicated Cache
Each server has the entire cache
Cache updates done to all servers
synchronously. So, they’re slower.
Each clients connects to only one
cache server. All servers active.
Good for read-intensive scenarios Server 1 Server 2
Replicated Cache
1 2
3 4
5 6
Active
Synchronous Updates
Remote Clients (Web/App Servers)
1 2
3 4
5 6
Active
24. Alachisoft
NCache 24www.alachisoft.com
Caching Topologies
Partitioned Cache
Extremely scalable
Location transparency
Good for large cache clusters
Distribution map sent to all clients
at runtime
No replication available
Server 1 Server 2
Partitioned Cache
Remote Clients (Web/App Servers)
21
Partition 1
43
Partition 2
Distribution
Map
Distribution
Map
25. Alachisoft
NCache 25www.alachisoft.com
Caching Topologies
Partition-Replica Cache
Each partition has one replica on a
different server. All created
automatically.
Async & Sync replication options
Extremely fast & scalable
Reliability due to replicas
Server 1 Server 2
Partition-Replica Cache
Remote Clients (Web/App Servers)
21
Partition 1
43
Replica 2
43
Partition 2
21
Replica 1
Distribution
Map
Distribution
Map
26. Alachisoft
NCache 26www.alachisoft.com
Conclusion
1. Distributed Cache is Better for Runtime Data Sharing
Faster and more scalable
Likely to be already available for your app
2. NCache is the leading distributed cache for .NET
More feature rich product in the market
27. Alachisoft
NCache 27www.alachisoft.com
Next Steps
Download NCache 60-Day Trial (Fully Working)
http://www.alachisoft.com/download.html
Contact us for Personalized Architectural Demo
Email: sales@alachisoft.com. Phone: +1 (925) 236-3830