๐Ÿญ๐Ÿฌ ๐—”๐—ฃ๐—œ ๐—ฎ๐—ป๐—ฑ ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐— ๐—ถ๐˜€๐˜๐—ฎ๐—ธ๐—ฒ๐˜€ ๐—•๐—ฒ๐—ณ๐—ผ๐—ฟ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜๐—ถ๐—ผ๐—ป

You wrote your first API. It works on your machine. Then you deploy to production and everything breaks.

I have seen this happen many times. Most mistakes are predictable. You can avoid them if you know what to look for.

Here are 10 common blunders and how to fix them.

๐Ÿญ. ๐— ๐—ถ๐˜€๐˜€๐—ถ๐—ป๐—ด ๐—œ๐—ฑ๐—ฒ๐—บ๐—ฝ๐—ผ๐˜๐—ฒ๐—ป๐—ฐ๐˜† A user clicks "Pay" twice because their signal drops. Without protection, you charge them twice.

๐Ÿฎ. ๐—ข๐—ณ๐—ณ๐˜€๐—ฒ๐˜ ๐—ฃ๐—ฎ๐—ด๐—ถ๐—ป๐—ฎ๐˜๐—ถ๐—ผ๐—ป Using LIMIT and OFFSET is slow on large tables. The database must scan and discard every row before the offset.

๐Ÿฏ. ๐—ก๐—ผ ๐—”๐—ฃ๐—œ ๐—ฉ๐—ฒ๐—ฟ๐˜€๐—ถ๐—ผ๐—ป๐—ถ๐—ป๐—ด Changing an endpoint without a version number breaks every client using your API.

๐Ÿฐ. ๐—•๐—ฎ๐—ฑ ๐—˜๐—ฟ๐—ฟ๐—ผ๐—ฟ ๐—ฅ๐—ฒ๐˜€๐—ฝ๐—ผ๐—ป๐˜€๐—ฒ๐˜€ Vague errors make debugging hard.

๐Ÿฑ. ๐—œ๐—ป๐—ฐ๐—ผ๐—ป๐˜€๐—ถ๐˜€๐˜๐—ฒ๐—ป๐˜ ๐—ก๐—ฎ๐—บ๐—ถ๐—ป๐—ด Mixing snake_case and camelCase frustrates developers.

๐Ÿฒ. ๐—จ๐—ป๐—ป๐—ฒ๐—ฐ๐—ฒ๐˜€๐˜€๐—ฎ๐—ฟ๐˜† ๐——๐—ฒ๐—ป๐—ผ๐—ฟ๐—บ๐—ฎ๐—น๐—ถ๐˜‡๐—ฎ๐˜๐—ถ๐—ผ๐—ป Copying data to avoid JOINs causes data integrity issues.

๐Ÿณ. ๐—•๐—ฎ๐—ฑ ๐—œ๐—ป๐—ฑ๐—ฒ๐˜…๐—ถ๐—ป๐—ด Too few indexes make queries slow. Too many indexes make writes slow.

๐Ÿด. ๐—ง๐—ต๐—ฒ ๐—ก+๐Ÿญ ๐—ค๐˜‚๐—ฒ๐—ฟ๐˜† ๐—ฃ๐—ฟ๐—ผ๐—ฏ๐—น๐—ฒ๐—บ Running one query to get a list, then one query per item in that list, kills performance.

๐Ÿต. ๐—•๐—น๐—ผ๐—ฐ๐—ธ๐—ถ๐—ป๐—ด ๐—ฆ๐—ฐ๐—ต๐—ฒ๐—บ๐—ฎ ๐—–๐—ต๐—ฎ๐—ป๐—ด๐—ฒ๐˜€ Running ALTER TABLE on a massive table can lock it for hours. This causes outages.

๐Ÿญ๐Ÿฌ. ๐—•๐—ฟ๐—ฒ๐—ฎ๐—ธ๐—ถ๐—ป๐—ด ๐—–๐—ต๐—ฎ๐—ป๐—ด๐—ฒ๐˜€ ๐˜๐—ต๐—ฎ๐˜ ๐—ฑ๐—ผ๐—ป'๐˜ ๐—น๐—ผ๐—ผ๐—ธ ๐—น๐—ถ๐—ธ๐—ฒ ๐—ถ๐˜ Changing a timestamp format or a validation limit is a breaking change.

Which mistake did you learn the hard way? Tell me in the comments.

Source: https://dev.to/sarim_nadeem_888180307df8/10-api-and-database-blunders-every-beginner-makes-and-how-to-fix-them-before-production-bites-back-5ajc