Design a transportation payment method

For example design a payment system for New York’s MTA. Tell how you would handle thousands of requests per second. Also how will you handle the different notifications systems such as text alert. How would you handle faults? Was asked this on an onsite round.

https://leetcode.com/discuss/interview-question/system-design/305388/design-a-transportation-payment-system

One solution

Basically you need to build two services, one to handle payment and one to handle notifications (can be email, whatsapp, text, etc.).

Payment system’s responsibility to only deduct the payment using any of the payment gateways and call notification service to notify client. Payment needs to be done real-time and you have to handle client request through some HTTP API, so that you can show gateway page, amount, confirmation etc. After user consent is given you process the payment and queue a message to notification system to send alert. For payments, you can use any noSQL database, since we don’t have any relation as such and you get fast read/write.

Notification service’s responsibility to notify users through channels. Notifications can be near realtime, so you can make use of queue/worker, so that you can autoscale your workers whenever there are more messages in queue. Workers are responsible for sending alerts. More workers you have, faster you process notifications to users. You can even distinguish different workers for different communication channel and scale them separately. As database you can use any noSQL, cause I don’t see any relation as such.

You should ask more specific questions to interviewer during system design rounds to understand the scenario better.

  • Replies
    using SQL or noSQL

  • For payments it needs to be SQL . you want to maintain consistency in such highly atomic operations.

  • Need backup servers and replica in case some application servers or database severs fail.