Skip to content

Conversation

dvoet
Copy link
Contributor

@dvoet dvoet commented Feb 25, 2025

https://broadworkbench.atlassian.net/browse/CORE-308

An observation from the logs is that for orch, the connect timeouts only occur using Sam's client library. Orch only uses sam client library for 2 calls,getUserStatusInfo and bulkMembershipUpdateV2. All other calls use a hand rolled client using akka http. Granted, getUserStatusInfo is called on every api call so the prevalence of the error might be biased towards that call.

The crux of this change is to use a shared instance of the okhttp client configured for large bandwidth to sam. As it was, each new ApiClient was creating a bunch of resources for single use that were meant to be reused. This will hopefully lead to fewer connection attempts and fewer timeouts.

An ancillary change is to move a call to sam into the SamDAO (I don't know why it wasn't there to start... probably plumbing issues).

Have you read CONTRIBUTING.md lately? If not, do that first.

I, the developer opening this PR, do solemnly pinky swear that:

  • I've followed the instructions if I've made any changes to the API, especially if they're breaking changes
  • I've updated the FISMA documentation if I've made any security-related changes, including auth, encryption, or auditing

In all cases:

  • Get two thumbsworth of review and PO signoff if necessary
  • Verify all tests go green
  • Squash and merge. Make sure your branch deletes; GitHub should do this for you.
  • Test this change deployed correctly and works on dev environment after deployment

@dvoet dvoet requested a review from a team as a code owner February 25, 2025 19:57
@dvoet dvoet requested review from kevinmarete and marctalbott and removed request for a team February 25, 2025 19:58

private def newApiClient(user: WithAccessToken) = {
val apiClient = new ApiClient()
val apiClient = new ApiClient(httpClient)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the important change. httpClient is reused across all sam calls using the client library

Comment on lines +62 to +63
dispatcher.setMaxRequests(1000)
dispatcher.setMaxRequestsPerHost(100)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am just guessing here. I will circle back to make these configurable if this ends up helping

implicit val executionContext: ExecutionContext
implicit val materializer: Materializer

val samDao: SamDAO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes in this file are related to moving the getUserStatusInfo call to samDAO


implicit override val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

val samDao: SamDAO = mock[SamDAO](RETURNS_SMART_NULLS)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use mockito now instead of a mock http server

@dvoet dvoet enabled auto-merge (squash) February 25, 2025 21:04
@dvoet dvoet merged commit c108f16 into develop Feb 25, 2025
13 checks passed
@dvoet dvoet deleted the use_okhttp_rite branch February 25, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants