Friday 14 January 2011

Big improvements to service for Tesco Finder app

I've just sent into live an update to the API service supporting Tesco Finder application. The focus has been on improving performance and accuracy of the service for the ever-increasing number of Tesco Finder users.

  1. The "nearest branches" feature is now much more accurate. Before the update, the API tended to favour nearest branches by longitude (east-west of your location) over latitude (north-south), resulting in branches further away but in an east-west direction ending up higher up the list than those north-south. The API was behaving like this because changes in longitude are much greater for the same distance on the ground than changes in latitude where UK and Ireland are located on the planet's surface. I had over-compensated for this effect in my arithmetic. In fact, for longitude the conversion to distance is the same as latitude except the value is multiplied by the cosine of the latitude. Lesson learned!
  2. Obtaining product information is much faster. This works by pooling the search session to a special account on our grocery API so all Tesco Finder users share the same login session - since you don't have to login as anyone to use Tesco Finder, the API has to login to a special grocery account in order to search for products and provide pricing and offer information. Before now, each search was preceded by a login for that user - nice and safe in the multi-threaded computing environment of the API. Sharing the same login session is a lot trickier because that session has to be locked to each user in turn while the search takes place. Fortunately it's so quick that the queue of search requests waiting in turn to lock the session does not build up.
Sharing resources in a multi-tasking web environment can be a dangerous game. Each process (usually a computer script preparing a web page to be sent to your browser - we call this a 'thread') must lock the resource so it doesn't get altered by other threads until this thread is done. If one thread keeps the lock for too long, the backed-up threads (usually other people waiting for their web page to arrive) can grow quickly. If the backup is severe and default memory allocation is exhausted, the operating system starts trying to manage memory by swapping it to and from disk, hitting CPU load and disk response times and slowing things down more. Soon the server hits the digital cliff and the infamous HTTP 500/Too Many Users results, or the server just stops responding at all.

That's why it's taken some time and lot of testing to ensure that this programming pain is worth the performance improvement for Tesco Finder customers. I'm glad to say it has worked out well - it's now live as of 1:30pm today.

2 comments:

  1. my poor Android phone...

    just itching to order some groceries :(

    ReplyDelete
  2. Hi Nick. Big fan of the blog. I work in Corporate Marketing at Tesco HQ.

    I'm very impressed that you've considered the curvature of the earth in bringing out the list of nearby stores. Something I've never considered! However, i have a couple of questions, if I may.

    1. Why doesn't the app use drivetime data, rather than straight line distance? This data is available at Tesco, and is a more accurate view of a customer's nearest store, esp in urban areas.

    2. Also, as accurate as the calculation might be, if the store location data is incorrect (store location is a few 100m out), surely this would have more impact on the overall accuracy? How do you vouch for the accuracy of over 2,000 stores?

    Gareth

    ReplyDelete

As this blog grows in readership - and because it carries the Tesco brand - I have had to become more careful about the sort of comments that are acceptable. The good news is that I'm a champion of free speech so please be as praising or as critical as you wish! The only comments I DON'T allow through are:

1. Comments which criticise an individual other than myself, or are critical of an organisation other than Tesco. This is simply because they cannot defend themselves so is unfair and possibly libellous. Comments about some aspect of Tesco being better/worse than another equivalent organisation are allowed as long as you start by saying "in my personal opinion.." or "I think that...". ... followed by a "...because.." and some reasoned argument.

2. Comments which are totally unrelated to the context of the original article. If I have written about a mobile app and you start complaining about the price of potatoes then your comment isn't going stay for long!

3. Advertising / web links / spam.

4. Insulting / obscene messages.


Ok, rules done - now it's your go: