DCSIMG
Hagay Albo's Blog

Hagay Albo's Blog

a

אתר רסט עלה עם גרסא חדשה לאתר

בשעה טובה אתר רסט עלה היום -25-5-2009 לאוויר.

לאחר חודשים של עבודה עלה אתר רסט החדש לאוויר , בשלב זה עלה האתר במה שנקרא עליה שקטה לאוויר כלומר הגלישה אל העתר נעשת דרך כניסה ישירות לכתובת http://new.rest.co.il/
או ע"י לחיצה על אחד הבאנרים המוצגים באתר הקיים המפנים לגרסת הBeta של האתר החדש.

אתר רסט עבר שיפוץ משמעותי גם בעיצוב וגם טכנולוגיה.

עיצוב

העיצוב נעשה ע"י מנטיס וניתן לראות קו חדש .




טכנולוגית

האתר החדש נבנה ב ASP.NET 3.5  ב C# עם דגש רב לCaching וצמצום משמעותי של פניות לבסיס הנתונים דבר אשר גרם בעיות באתר הישן.
בנוסף שרתי הIIS הוחלפו ל IIS7 על Windows 2008 Web Edition.

מוזמנים לגלוש : http://rest.co.il/ וללחוץ על אחד הבאנרים שמעבירים לאתר החדש.

Posted: May 24 2009, 09:36 PM by Hagay Albo | with no comments
תגים:

Velocety CTP3 Integration In Zap Price Comparison

As velocity CTP3 was released, I as CTO of D-Group  witch includes Zap thought that zap can benefit allot from Velocity . so the next day we implemented velocity CTP 3.

The integration was fast (couple of hours) and the goals where:

1)      Reduce queries from the DB and by that reduce DB resources.

2)      Improve response time for pages to client

3)      Enlarge the regular local cache mechanize we had.

Until Velocity integration, Zap has used the regular cache given by ASP.NET in each one of the web servers.

The problems we had with the old solution where:

1)      Not enough space in the memory to hold all the data.

2)      The data had to be reloaded for each web Server

3)      No high availability.

So we took the filtering function from Zap and implemented it throgh Velocity.
The filtering function is when a client chooses to filter up a category, let's say you are in Televisions category and now you want to filter only Samsung television and then only LCD and then only 21-25 inch.

Every press for changing the filters recalculates all the data directly from the Data Base.
 We couldn’t keep all this data in the local cache because all the problems mentioned above.

So here came velocity with a simple implementation of Velocity (two standard servers for the beginning) after two weeks we saw that we reduced the queries to the Data Base by more than 70% .

And the most important thing is that the response time of a page that had a "Hit" from the velocity was in average faster by more than 500% than a page that his filter was not in the cache "Miss".

For Zap velocity CTP3 that was installed, without a doubt has improved performance, reduced pressure from the Data Base and improved the survivability of the application.
We intend to implement Velocity on all of the data and not only filters soon.

 

SQL dependency with Velocity CTP3

Velocity CTP3 was released on April 8 and one of the first things that interested me is the ability of removing items from the cache when they change in the database.
Like the known SQL dependency in the .NET cache.( SqlCacheDependency )

Unfortunatly Velocity CTP3 does not support SQL Dependency yet. (they are supposed to support this ability in the future)
Here ill show a simple trick for creating SQL dependeny and attaching it to Velocity.

First we will create a singltone DataCache :

static readonly object padlock = new object();

public static DataCache GetCache()
{


lock (padlock)
{


if (_cache == null)
{

//Define Array for 1 Cache Host

DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];

//Specify Cache Host Details
// Parameter 1 = host name
// Parameter 2 = cache port number
// Parameter 3 = cache service name

servers[0] = new DataCacheServerEndpoint("ServerName", +22233, "DistributedCacheService");

//Select Routing or Simple Client
// False = Simple Client (no routing table)
// True = Routing Client

bool routingClient = false;

//Select local cache if desired
// True = Enable local cache
// False = Disable local cache

bool localCache = false;

//Disable exception messages since this sample works on a cache aside

DataCacheFactory.DisableLogSinks();

//Pass configuration settings to cacheFactory constructor

DataCacheFactory _factory = null; _factory = new DataCacheFactory(servers,

routingClient, localCache);

//Get reference to named cache called "NamedCache"

_cache = _factory.GetCache("default");

}

}

return _cache;

}

Now we will create a CacheItemRemovedCallback delegate :

public static event System.Web.Caching.CacheItemRemovedCallback removeRegionDelegate;

And a method that will be called every time the SQL dependency event is trigered

static void _Default_removeRegionDelegate(string key, object value, System.Web.Caching.CacheItemRemovedReason reason)

{

if (_cache != null)

{

_cache.ClearRegion(
"RegionName");

}

}

Now all wee need to do is add an empty object to the regular .NET cache with an sqlDependency and add the removeRegionDelegate so every time the item is removed from the cache the _Default_removeRegionDelegate method is called and clears all the items from the Velocity region.

if (System.Web.HttpContext.Current.Cache["dependency"] == null)

{

SqlCacheDependency sqlDependency = new SqlCacheDependency("Name", "connections"); //dependency information 

removeRegionDelegate += new System.Web.Caching.CacheItemRemovedCallback(_Default_removeRegionDelegate);

System.Web.HttpContext.Current.Cache.Insert("dependency", " ", sqlDependency, System.DateTime.Now.AddDays(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.NotRemovable, removeRegionDelegate);

}

  • The creation of the local cache "dependency" is suppose to run once (Global.Asax Application_Start)
  • If you have many clients you can make shure it runs only on one of the clients buy checking if the region is full before clearing the region

For conclusion

This litle code is a workaround for enabling SQL dependency for velocity until they will publish a version that includes this feture.