Recently, I shared how reducing multiple API calls improved performance. This time, I ran into a different issue. My API response looked fine… until I saw the payload size. While working on a feature, everything was working as expected. But the response felt heavier than it should be. After checking, I realized I was returning full objects, even when only a few fields were actually needed. So for a single request, I was sending a large JSON response unnecessarily. I made a small change: Instead of returning everything, I started sending only what the client actually needs. Used DTOs to control the response and removed unused fields. That made a clear difference: - Smaller payload - Faster response - Cleaner API Last time, the issue was too many API calls. This time, it was too much data in one call. (Check the previous post: https://lnkd.in/gxSKFVbk) Sometimes performance issues are not about complex fixes… they’re about reducing unnecessary work. #Java #BackendDevelopment #SpringBoot #API #Performance #LearningInPublic
Or use graphql, make apps more consise less dtos and you expose only what you are willing to share.
reducing payload does matter network cost, serialization, and client parsing all add up. But yeah, the real win is when you combine it with fetching only what you need from the DB. DTOs + optimized queries together is equal to actual performance gain
Get only required data from db .... reducing json doesn't make any sense...dtos is only for sending required data to client not for Speed