Showing posts with label distributed cache. Show all posts
Showing posts with label distributed cache. Show all posts

Monday, September 22, 2014

Realtime data exchange across enterprise using udp

Hello friends, its been long time since I wrote something on this blog site. For some time I off tracked myself from core GIS. Was busy in doing some real time messaging framework design. Did something cool on udp based reliable messaging and gis information exchange. The technology that I developed is all about sharing realtime data across enterprise through radio network. Later found somebody in the market doing similar thing. Have a look on Realtime Innovations. It does quite good stuff.

Mostly distributed caching/load balancing happens based on TCP at the lower level. But the same thing can be done using UDP. UDP by itself unreliable which means packet that is sent for delivery may or may not reach the destination. There may be chances of duplicate packets across nodes while on radio network. There may not be any packet sequencing while reaching the destination. All these are headache of using UDP. Still, people uses UDP for better bandwidth use and its multicast/broadcast facility.

I want to share some quick tips to other developers who are new to java socket programming to make their life easier while doing udp socket communication:
  1. DO usual socket creation steps like creating DatagramSocket/MulticastSocket based on your requirement
  2. Make sure you have set reusable address property on the socket object. It helps you you bind another socket on the same port
  3. Join a multicast group if you want to receive multicast packets
  4. MOST important set socket send/receive buffer size properly set. By default it is 8KB for a linux machine. Set some big value (i.e. 2MB) based on the traffic on the receiving port
  5. Prepare each packet below MTU level(i.e 1024 bytes). Generally network MTU(maximum transmission unit) is 1500 bytes. By making packet size below MTU, you overcome the risk of network packet fragmentation during transmission.
  6. Close your socket after job is done
  7. Leave multicast group
Feel free to contact me.



Friday, July 10, 2009

"Velocity" Is it really good compared to Memory Mapping?

I am writing this blog out of my own experience in using "Velocity" till CTP3 which I thought to be promising distributed in-memory caching technology:

Microsoft came up with their new project code named "Velocity" for distributed in-memory caching. As a learner i started learning this technology and found that there are already lot of players in this field of distributed caching. As a wild guess i thougt it might have come up with some new and faster approach to read bulk amount of data with their concept of Region,Tag enumerator and then LINQ and WCF.
When I test my application in compared to unmanaged memory mapped file(over network) against velocity caching, i find memory mapping is far far better. though in this case memory mapped file is a static one i cant update it, whereas velocity will allow me do that.

Let me clarify a bit about my sample application :
I have a static binary file, stores spatially indexed(quad tree) and formatted data ,which stores millions record having line geometry. I can traverse them throgh my spatial iterator very fast and can filter my spatial data very fast. But here only one problem i have i can't update it, i need to rebuild the spatial index again. During live operation, I synchronize my data with oracle back-end if any other user edited/added any record and then serve it to my client application. I was just wanted all these facility from "Velocity".

So, i indexed my spatial data key in Regions with specific tags(quad node name where it fits,identifier to locate geometry object in the named cache, any other attribute which can be indexed) and stored actual data in NamedCache. As soon as a new record comes my SpatialIndexing service finds which quad node its going to fit then it posts it to Region and NamedCache respectively.

Now i tested my application using memory mapping and velocity in .Net 3.5 environment. Yes through a PIA i've i've accessed the binary file through memory mapping. In Velocity case i used following settings-
1 - Local Cache on/off + no secondary
2- With secondaries + local cache on/off
3- Simple/Routed

Used SQL server cluster configuration. 2 nodes on the cache tier and all three nodes are linked to a common network(LAN).
1 -Quorum node - VISTA 64bit,4GB RAM,Single core
2- Node2 - XP32bit,4GB RAM,dual core

Though there were interop calls between managed and unmanaged environment, memory mapping worked ~15 times faster compared to Velocity if there is no local cache. For local cache case both are slight compairable(memory maping still leads!!), but i can't enable local cache as it will eat up my application address space. Fortunately in CTP3 we can limit numberof objects that can be stored locally and they will be evicted as a regular eviction mechanism.

I'm going to make my application run on memory mapping only. Will see if memory mapping of .Net 4.0 can help me further to gain performance.