# Optimizing the Backend: Examples of slow responses in O3

**URL:** <https://talk.openmrs.org/t/optimizing-the-backend-examples-of-slow-responses-in-o3/40716>\
**Category:** Development\
**Tags:** platform, performance, o3\
**Created:** [October 17, 2023, 1:58pm UTC](https://talk.openmrs.org/t/optimizing-the-backend-examples-of-slow-responses-in-o3/40716 "2023-10-17T13:58:22Z")\
**Posts on this page:** 1\
**Showing post:** 39

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 26, 2024, 1:01am UTC](https://talk.openmrs.org/t/optimizing-the-backend-examples-of-slow-responses-in-o3/40716/39 "2024-04-26T01:01:49Z")

</div>

@janflowers I would vote for working on individual tickets as these things are discovered.

For the `https://test3.openmrs.org/openmrs/ws/fhir2/R4/Location?_summary=data&_count=50&_tag=Login+Location` call that @lumuchris256 listed in his report, my recommendation is that we change it from using FHIR to the end point provided by the webservicesrest module: `https://test3.openmrs.org/openmrs/ws/rest/v1/location?tag=b8bbf83e-645f-451f-8efe-a0db56f09676&limit=50`

This call is already 4 times faster than the FHIR one. And i have just made a commit to make it 2 times faster, than what it already was, with this ticket: [[RESTWS-934] - OpenMRS Issues](https://openmrs.atlassian.net/browse/RESTWS-934) hence eventually making it 8 times faster than the FHIR one. Which, on my computer, while connecting to a local O3 backend, translates from an average of 300ms to 35ms.

And when a custom representation of something like `custom:(name,uuid)` is used for the webservicesrest end point, it will also save on the bandwidth, as less data is sent over the wire.

The performance problems of the FHIR end point are caused by these two lines below during the translation from OpenMRS to the FHIR format:

1. [openmrs-module-fhir2/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/LocationTranslatorImpl.java at 2.0.0 · openmrs/openmrs-module-fhir2 · GitHub](https://github.com/openmrs/openmrs-module-fhir2/blob/2.0.0/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/LocationTranslatorImpl.java#L102)

2. [openmrs-module-fhir2/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/LocationTranslatorImpl.java at 2.0.0 · openmrs/openmrs-module-fhir2 · GitHub](https://github.com/openmrs/openmrs-module-fhir2/blob/2.0.0/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/LocationTranslatorImpl.java#L109)

This results into extra unnecessary database calls for each location that is returned. With the `_count=50` parameter, it means 50 \* 2 = 100 extra database calls.

---

_[View the full topic](https://talk.openmrs.org/t/optimizing-the-backend-examples-of-slow-responses-in-o3/40716)._
