Originally published on Aws Builders — Read the original article
A customer looks up a Pix key, checks the recipient’s name, and closes the app. Days later, one integration is still sending lookups at its usual rate, with healthy latency and almost no payments. When would you open an investigation?
Pix is Brazil’s instant payment system. I worked on its architecture at my institution and helped build the rate limiter for key lookups. The tricky part was deciding when a lookup should spend a token and when a later payment should return one.
What a Pix lookup costs
A Pix key lets a payer look up a recipient without typing their bank account details. The institution queries a directory operated by Brazil’s central bank, known as DICT, so the payer can check who will receive the money. Repeated reads also create an opportunity to collect personal data. [1]
A token bucket with feedback from the payment
A token bucket holds a limited number of permits. An incoming request needs a permit to proceed.…