🚨 Investigating Timeout Bottlenecks in OpenMRS Endpoints

Hey everyone! :waving_hand:

As part of my @GSOC project with @OpenMRS, I’ve been working on improving the performance of the OpenMRS 3.x backend. In this thread, I’ll walk through specific API endpoints that are facing timeout issues, backed by metrics from our Gatling testing reports. :bar_chart:

:link: Report: Gatling Stats - Global Information


:thread: URL 1:

:one: /openmrs/ws/rest/v1/patient – Get Patients

Used to fetch patient data with detailed fields.

Request URL:

/openmrs/ws/rest/v1/patient?q=SEARCH_QUERY&v=custom:(patientId,uuid,identifiers,display,patientIdentifier:(uuid,identifier),person:(gender,age,birthdate,birthdateEstimated,personName,addresses,display,dead,deathDate),attributes:(value,attributeType:(uuid,display)))&includeDead=false&limit=50&totalCount=true

:no_entry: Timeout %: 28.64%

:stopwatch: Median Response Time: ~51s


:thread: URL 2:

:two: /openmrs/ws/rest/v1/emrapi/inpatient/request – Get Inpatient Request

Used to fetch inpatient data related to admission/transfer requests.

Request URL:

/openmrs/ws/rest/v1/emrapi/inpatient/request?dispositionType=ADMIT,TRANSFER&dispositionLocation=LOCATION_UUID&v=custom:(dispositionLocation,dispositionType,disposition,dispositionEncounter:full,patient:(uuid,identifiers,voided,person:(uuid,display,gender,age,birthdate,birthtime,preferredName,preferredAddress,dead,deathDate)),dispositionObsGroup,visit)

:no_entry: Timeout %: 4.05%

:stopwatch: 95th Percentile: ~49s


:thread: URL 3:

:three: /openmrs/ws/fhir2/R4/Observation – Get Lab Results of Patient

Fetches lab observations via FHIR for a given patient.

Request URL:

/openmrs/ws/fhir2/R4/Observation?category=laboratory&patient=PATIENT_UUID&_count=100&_summary=data

:no_entry: Timeout %: 2.95%

:stopwatch: Max Response Time: ~60s


:thread: URL 4:

:four: /openmrs/ws/fhir2/R4/Observation – Get Patient Observations

Returns filtered clinical observations for the patient using concept codes.

Request URL:

/openmrs/ws/fhir2/R4/Observation?subject:Patient=PATIENT_UUID&code=OBSERVATION_CODES&_summary=data&_sort=-date&_count=100

:no_entry: Timeout %: 2.93%

:stopwatch: 99th Percentile: ~60s


:light_bulb: A Key Insight

In our current setup, only 250 patients are repeatedly used across simulations. Over time, this leads to data buildup per patient — including clinical forms, observations, and historical records.

For some endpoints (like observations and lab results), this accumulated load per patient could be a major contributor to timeouts.

But it’s also important to note: not all slowdowns are due to this.

@dkayiwa @ibacher @jayasanka @bawanthathilan

1 Like

Does the timeout percentage depend on the search query parameter?

We use “jay” as a search query parameter and it stays static.

Are we able to look at backend logs for timeouts?

Timeout happens when request takes over 60s to respond. It’s very likely that O3-4765: Improved FHIR Get Lab Results endpoint performance by rkorytkowski · Pull Request #569 · openmrs/openmrs-module-fhir2 · GitHub will improve performance for FHIR endpoints using Concepts as it introduced cache for Concept resource so I would re-test when merged.

1 Like

The server logs are available for the respective runs in the links below

The runs with name Run Performance Tests are the once to open and once opened the server-logs are present in the artifacts( server-logs).