How-To Configure indeXus.Net Shared Cache

there are 3 different configuration files available:
  • server configuration file
  • notify configuration file -> check this link notifyconfiguration (will be soon available)
  • client configuration file -> check this link clientconfig (will be soon available)

Server configuration file

NOTE: since the pre_release_1.0.2.129 the server needs a definition within the configSection

we will split the description it into 5 different sections:
  • configSection Element
  • appSettings Element
  • replicatedSharedCache Element
  • nlog Element
  • optional default .Net system diagnostics Element

configSection Element

Definition area for the additional config elements of replicatedSharedCache and nlog which is described below.
check msdn for more information about it ( http://msdn2.microsoft.com/en-us/library/aa903350.aspx )

	<configSections>
		<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
		<section name="replicatedSharedCache" type="MergeSystem.Indexus.WinServiceCommon.Configuration.Server.IndexusServerProviderSection, MergeSystem.Indexus.WinServiceCommon"/>
	</configSections>

appSettings Element

this element contains general setting information which the server needs to run, to miss one of them would cause the application to use the a default value for each of them.
check msdn for more information about it ( http://msdn2.microsoft.com/en-us/library/ms228154.aspx )

<appSettings>
		<!--Version Number, same like in assemblies-->
		<add key="SharedCacheVersionNumber" value="1.0.2.125" />
		<!--Should information be logged-->
		<add key="LoggingEnable" value= "1" />
		<!--Location of Cache Service-->
		<add key="ServiceCacheIpAddress" value="192.168.212.21" />
		<!--Location of Cache Service, the port number-->
		<add key="ServiceCacheIpPort" value= "48888" />
		<!--
			1 - Enabled
			0 - Disabled
			remember to configure the section of replicatedSharedCache.
		-->
		<add key="ServiceFamilyMode" value= "0" />
		<!--
			If the service is running in debug mode
			1 - Enabled
			0 - Disabled
			NOTE: its recommended to run the server in debug mode, you 
			will receive much more log information.
			-->
		<add key="ServiceCacheDebugMode" value= "1" />
		<!--
			The maximum size of the objects in the Cache in MB.
			To make it unlimited, use value -1 which is the default
			in case of -1 you can receive OutOfMemoryException when the server is 
			not able anymore to receive data.
		-->
		<add key="CacheAmountOfObjects" value= "150" />
		<!-- 
				If the cache received the fillfactor it will start to throw away unused items from the cache
						suggested is a value between: 85% - 95%
				Default value is 90%
		-->
		<add key="CacheAmountFillFactorInPercentage" value= "95" />
		<!--
			- CacheItemPriority: A new option will be created where objects which are added to the cache receives a priority attribute.
			- LRU: Least Recent Used: The objects with the oldest requests will be deleted
			- LFU: Least Frequently Used: Means the object's witch are used less will be deleted from the cache / if all objects are used in same frequency 
			  the objects will be used in a randomized order
			- Timebased: The objects with the smallest time left in the cache will be deleted, in case all objects are used with max time, they will be deleted randomized
			- SIZE: Delete always biggest objects until it received the size of Fill-Factor 
			- Lowest-Latency-First [LLF]: Delete smallest objects until configured Fill-Factor reached
			- Hybrid: Makes a combination between several parameters: TimeTaken, Amount of Requests, Size, Cache Life Time each parameter receives a number
			  between 1 - n and those with the highest / lowest numbers will be deleted until configured Fill-Factory reached.
			
			Keys you can use: "CACHEITEMPRIORITY", "LRU", "LFU", "TIMEBASED", "SIZE", "LLF", "HYBRID"
		-->
		<add key="ServiceCacheCleanup" value="LRU" />
		<!--
			Expire thread interval, if the cache contains data which expires 
			this background thread cleans the cache up [milliseconds].
			1  sec  -> 1000
			30 sec  -> 30000
			1  min  -> 60000
			1  hour -> 3600000
			1  day  -> 86400000
			-> do not define a bigger value then this, the system will fail to read it - its an int 32 value
		-->		
		<add key="ServiceCacheCleanupThreadJob" value= "720000" />
		<add key="TcpServerMaxThreadToSet"	value="-1"/>
		<add key="TcpServerMinThreadToSet"	value="-1"/>
	</appSettings>

replicatedSharedCache Element

The replicatedSharedCache element are defines your additional instance within your environment. Based on the provided / configured information indeXus.Net SharedCache will make a replication to the instances if they are available. Please notice that to enable replication you will have to enable the following configuration option within appSettings element: ServiceFamilyMode - "1". If this option is disabled the server does not make any replication.

check the following links for information about providers ( http://msdn2.microsoft.com/en-us/library/4ksaf9z5(VS.71).aspx or http://weblogs.asp.net/scottgu/archive/2006/04/13/442772.aspx )

	<replicatedSharedCache defaultProvider="ServerSharedCacheProvider">
		<replicatedServers>
			<!-- DO NOT DEFINE THE INSTANCE ITSELF !!! IT WILL BE AUTOMATICALLY REMOVED DUE A STARTUP CHECK -->
			<add key="SrvZh03" ipaddress="192.168.212.21" port="48888" />
			<add key="SrvZh02" ipaddress="192.168.212.37" port="48888" />
		</replicatedServers>
		<providers>
			<add
        name="ServerSharedCacheProvider"
        type="MergeSystem.Indexus.WinServiceCommon.Provider.Server.IndexusServerSharedCacheProvider, MergeSystem.Indexus.WinServiceCommon">
			</add>
		</providers>
	</replicatedSharedCache>

nlog Element

for more information how to configure nlog, which is an external logging component please visit their website. they have great tutorials and descriptions about the different configuration options.

at indeXus.Net Shared Cache we decided to define following log files:
  • General - Logs any kind of information
  • Traffic - anything around logging
  • Tracking - tracking means which methods are called in which order.
  • Sync - all information around replication
  • Memory - some details about memory.

check nlog project website for more information about it ( http://www.nlog-project.org/ ) - thanks mates it's a great product (y)

	<nlog autoReload="true" throwExceptions="true">
		<targets async="true">
			<target name="shared_cache_general"		type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\${date:format=yyyy-MM-dd}_shared_cache_general_log.txt"/>
			<target name="shared_cache_traffic"		type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\${date:format=yyyy-MM-dd}_shared_cache_traffic_log.txt"/>
			<target name="shared_cache_tracking"	type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\${date:format=yyyy-MM-dd}_shared_cache_tracking_log.txt"/>
			<target name="shared_cache_sync"			type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\${date:format=yyyy-MM-dd}_shared_cache_sync_log.txt"/>
			<target name="shared_cache_memory"		type="File" layout="${longdate}|${level:uppercase=true}|${aspnet-request:item=logSession}|${message}" filename="C:\temp\logs\${date:format=yyyy-MM-dd}_shared_cache_memory_log.txt"/>
		</targets>
		<rules>
			<logger name="General" minlevel="Debug" writeTo="shared_cache_general" final="true"/>
			<logger name="Traffic" minlevel="Debug" writeTo="shared_cache_traffic" final="true"/>
			<logger name="Tracking" minlevel="Debug" writeTo="shared_cache_tracking" final="true"/>
			<logger name="Sync" minlevel="Debug" writeTo="shared_cache_sync" final="true"/>
			<logger name="Memory" minlevel="Debug" writeTo="shared_cache_memory" final="true"/>
			<logger name="*" minlevel="Debug" writeTo="shared_cache_general"/>
			<logger name="*" minlevel="Info" writeTo="shared_cache_general"/>
		</rules>
	</nlog>

optional default .Net system diagnostics Element

in our config files we have a commented section which contains system.diagnostics information. normally this should be commented then it slows down the application by 90% but for debugging mode this is a very informative log.
have a read on msdn how to handle and work with this section - How to: Configure Network Tracing: http://msdn2.microsoft.com/en-us/library/ty48b824.aspx

	<system.diagnostics>
		<sources>
			<source name="System.Net" tracemode="includehex" maxdatasize="1024">
				<listeners>
					<add name="System.Net"/>
				</listeners>
			</source>
			<source name="System.Net.Sockets">
				<listeners>
					<add name="System.Net"/>
				</listeners>
			</source>
			<source name="System.Net.Cache">
				<listeners>
					<add name="System.Net"/>
				</listeners>
			</source>
		</sources>
		<switches>
			<add name="System.Net" value="Verbose"/>
			<add name="System.Net.Sockets" value="Verbose"/>
			<add name="System.Net.Cache" value="Verbose"/>
		</switches>
		<sharedListeners>
			<add name="System.Net"
        type="System.Diagnostics.TextWriterTraceListener"
        initializeData="network.log"
      />
		</sharedListeners>
		<trace autoflush="true"/>
	</system.diagnostics>

download

standard sample server configuration file: MergeSystem.Indexus.WinService.exe.config

Last edited Feb 13, 2008 at 6:08 PM by ronischuetz, version 15

Comments

No comments yet.