Peter Nguyen Team : Web Development Tags : Web Development

Increasing model deserialization speed with JSON.net

Peter Nguyen Team : Web Development Tags : Web Development

In one of the ecommerce websites I’ve recently been working on, I encountered a very strange issue when binding a large model in MVC 3.

It would just hang there, for one to two minutes, trying to bind the large model from JSON.

Upon further research – I discovered (along with the help of other developers) that the default model binding that MVC3 used to deserialise was JavascriptSerializer, which is very slow.

The speed I was getting was pretty unacceptable – it would be terrible user experience to have to wait one to two minutes to save your project in the cart.

One of the guys in the office then recommended to replace the binder with JSON.net, which saw a huge performance improvement, reducing the save time from roughly two minutes to 2-3 seconds!

Overall, performance was improved dramatically and the site (since it depended on JSON almost entirely) felt faster and more responsive.