Saturday, January 14, 2012

Video locking

A few months ago, we've added a feature that lets the owner of a video lock it. When a video is locked, no one can modify it, not even the video owner. This is sometimes useful for preventing accidental change to a video that's already subtitled and there's nothing more to do with it.

Of course, the video owner can unlock the video, and then anyone (who previously had access to the video) can update the video once again.

There was one bug - when a video is locked, you couldn't download its subtitles. Since the aim of this site is to support creating and sharing subtitles, this was really an annoying bug. But now it's fixed, and subtitles of locked videos can be downloaded.

So why did it take so long to fix it? Here we need to get a bit technical. is built using App Engine. Generally, this has been a blessing, as this environment is really easy to work with, and development speed is quite high, which is important for a hobby site that's being developed and maintained in spare time. It's also important that App Engine supports free hosting for small sites (like yt-subs).

But around Sep. 2011, Google announced a change in the App Engine pricing. Before the change, yt-subs was well below the free quota. After the change, yt-subs would cost something like a $1 a day. That's quite a lot for such a small app.

Google provides some tools and recommendations for improving the performance of App Engine applications, and one of those recommendations was to reduce the number of objects that are read/written from/to the database (datastore in App Engine terms).

Now, to watch a video with subtitles, we need to fetch tens or even hunders of subtitles - that's tens or hundreds of objects read from the database. Instead - when locking a video, we actually group all the subtitles into a single object stored in the database. It's a lot cheaper to read, but you can't update the subtitles while they're all grouped into a single objects, and that's why the video is locked.

So the whole locking / unlocking issue was rushed in to make billing for the application more sane, but at the cost of having some bugs that would be fixed later. BTW, there were many other changes besides locking and unlocking. Most of them were around using memcache, which really helped bringing down the cost of operation.

As it is now, yt-subs is not free, but falls within the minimum spent of an App Engine application ($9/month), and we're working hard to try and make it free again by optimizing it even further.

No comments:

Post a Comment