How to build a system like this?

If you dont know what an OysterCard is you have two choices, visit London or ask wikipedia. I would suggest you do the first but if you have time constraints you might want to opt for the latter.

The cards themselves will not record the amount of money pre-paid as this would be asking for hackers to figure it out and make cards which have "endless" credit. I have not found any documents which confirm this but we will just assume this is the case as the Oyster system has been deployed for quite a while now and no such attacks have been reproted.

So if the only thing on an OysterCard is a serial number, maybe a date of issue and say a date when it last "touched in" then a turnstile will need to make a query to somewhere to decide wheter a card is to be let into the system or not. A naive approach would be to have each turnstile send a request to a central server, wait for a reply and then open or tell the person to top up their account. The problems with this approach are:

There are about ten million people living in London, five million of which will commute during rush hour, working people, students and school kids. Rush hour is from about eight to about ten, two hours. This makes for roughly ten million transactions in two hours. Quite a high load, though manageable, I am not quite sure how many requests modern database systems can handle(not in burst mode) but it seems you could design such a system, just about, with enough mirroring and so on.

There remain two questions:

All this together suggests that we need to be able to verify a card within a short time and without talking to a central server. One possibility would be that turnstiles keep a copy of the database(maybe one gigabyte in size) and exchange patches with a central authority every few minutes. On a bus we would have to wait for a longer time, only major bus stops would have the equipment needed to sync the busses database.

It would also be desirable to be able to apply all patches concerning a given card quickly, for example when it is inserted into a top up machine or the user checks his balance in some other way. We need to give a rough estimate of the money left, maybe up to the last trip made. A day or even a few hours delay seem unacceptable. Again we should not rely on data stored on the card(say record last ten trips on the card to make it easier to find the right patches) because then people would not be able to check their account online or with a mobile.

Together with the problem of letting peole travel when the central system is unreachable

OysterCard (last edited 2008-03-27 13:54:17 by localhost)