Optimize profile service methods

The gateway service method is currently handling too much logic, resulting in significant delays. It takes 10–15 seconds to respond even for a small array of IDs (around 10 in length). At this rate, the response time will become unmanageable for larger arrays. The method needs to be refactored for better performance and scalability.
- Domain
- Profile
- Action
- refactor
- Department
- Backend
Log in to comment and vote
Comments6
Ivan Ligotino
May 5, 2025
@Elisur Freyesus the problem is also at ms level. if we have flows not requiring all that stuff, we should implement a new internal endpoint to provide a list of simple profiles (that is, no additional aggregation) by ids
[Deleted User]
May 5, 2025
@Ivan Ligotino
This is important because all other service also need
isFollowingfield aggregated.[Deleted User]
May 5, 2025
We can likely optimize performance by reducing redundant iterations over the same array at the gateway level, where multiple loops may currently be processing the same data unnecessarily. For example
populateUrlsmethod and below iteration belowconst profiles = response.data.map((profile) => ProfileGatewayRto.fromResponse(profile, storyViewsStatusMap[profile.id]), );Elisur Freyesus
May 9, 2025
exactly. one that looks like getProfileById … but for many ids this time.
@Yohannes Bekele will handle it
Elisur Freyesus
May 5, 2025
@Yohannes Bekele what do you think about this issue.
[Deleted User]
May 5, 2025
Yes @Elisur Freyesus, we can think possible optimizations for this. Probably, using different methods depending on the need of aggregation.