🏆 Milestone #62 ·
I'm working on integrating Stripe into my festival, basically allowing me to charge for access to festivals. The first version of the API that restricted information caused it to take 6.5 min to load my initial messages on login. I brought that down below 1300 ms.
I basically did it by un-normalizing my database. Most user interaction is by sending and receiving messages, each of which has a subject and a subject type. The first checked individually whether each subject/subject type combo was for a restricted subject. This could result in up to 3 db calls, and it did this for each message. Instead of checking for what events to restrict "on demand", I load all the active events on startup and cache it. Each hour I update the cache.