Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Improve groups.create endpoint for large amounts of members #30499

Merged
merged 17 commits into from
Oct 5, 2023

Conversation

sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Sep 26, 2023

Proposed changes (including videos or screenshots)

Some key changes:

  • changed the signature of createRoom function, to receive an IUser instead of a username. This was to prevent multiple trips to DB being done to fetch data from the same user
  • change how subscriptions are being created, now it creates an array of all subscriptions that need to be created and create them all at once using insertMany. Before they were being created synchronously one by one
  • update members count in the room object in a single command instead of single increments for each user
  • update user's __rooms property with a single updateMany command instead of multiple updateOne for each user/member provided

You can see below a load test comparing the old and the new code.

This test was performed by calling the endpoint providing an array with 100 members during 2 minutes by 5 simultaneous virtual users:
image

This one was also provided an array with 100 members but during 5 minutes by 5 simultaneous virtual users. another difference is that the user calling the API was already a member of 70k+ rooms:
image

we can see in both cases an improvement of around 50% either in number of requests or response time.

I still plan to add some tests.. I noticed we don't have tests covering even common use cases.

Issue(s)

Steps to test or reproduce

Further comments

@changeset-bot
Copy link

changeset-bot bot commented Sep 26, 2023

⚠️ No Changeset found

Latest commit: a524c2a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Merging #30499 (a524c2a) into develop (9aee190) will decrease coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #30499      +/-   ##
===========================================
- Coverage    50.87%   50.81%   -0.06%     
===========================================
  Files          809      803       -6     
  Lines        15020    15014       -6     
  Branches      2729     2733       +4     
===========================================
- Hits          7642     7630      -12     
+ Misses        6969     6959      -10     
- Partials       409      425      +16     
Flag Coverage Δ
e2e 48.54% <ø> (-0.02%) ⬇️
unit 62.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@sampaiodiego sampaiodiego changed the title chore: Improve create private room with large amount of members chore: Improve groups.create endpoint for large amounts of members Oct 2, 2023
@sampaiodiego sampaiodiego marked this pull request as ready for review October 3, 2023 18:31
@sampaiodiego sampaiodiego requested review from a team as code owners October 3, 2023 18:31
ggazzo
ggazzo previously approved these changes Oct 3, 2023
@sampaiodiego sampaiodiego added this to the 6.4.1 milestone Oct 4, 2023
@ggazzo ggazzo merged commit 6d46183 into develop Oct 5, 2023
@ggazzo ggazzo deleted the improve-create-room-multiple-users branch October 5, 2023 23:17
gabriellsh added a commit that referenced this pull request Oct 6, 2023
…ove/ui-caching

* 'develop' of github.com:RocketChat/Rocket.Chat:
  fix: Remove monitors query restrictions on update (#30550)
  chore: license v3 invalidation (#30585)
  chore: `CreateDirectMessage` a11y form improvements (#30581)
  chore: `CreateDiscussion` a11y improvements (#30583)
  chore: License v3 - behavior and limited reached triggers (#30561)
  chore: Improve `groups.create` endpoint for large amounts of members (#30499)
  feat: Monitors able to forward chats without joining (#30549)
  feat: Deployment Fingerprint (#30411)
  chore: fix flaky agents & custom fields tables tests (#30580)
gabriellsh added a commit that referenced this pull request Oct 9, 2023
…/mentionBot

* 'develop' of github.com:RocketChat/Rocket.Chat: (68 commits)
  fix: don't save the filter value on offlineMessageChannelName (#30576)
  feat: New permission to kick users (#30535)
  chore: improve message link focus (#30578)
  chore: Add required visual indication on `EditRoom` name input (#30589)
  fix: user dropdown menu position on RTL layout (#30490)
  chore: add missing `_id` field to `AtLeast` (#30592)
  test: Improve tests for legacy omnichannel analytics  (#30379)
  fix: Remove monitors query restrictions on update (#30550)
  chore: license v3 invalidation (#30585)
  chore: `CreateDirectMessage` a11y form improvements (#30581)
  chore: `CreateDiscussion` a11y improvements (#30583)
  chore: License v3 - behavior and limited reached triggers (#30561)
  chore: Improve `groups.create` endpoint for large amounts of members (#30499)
  feat: Monitors able to forward chats without joining (#30549)
  feat: Deployment Fingerprint (#30411)
  chore: fix flaky agents & custom fields tables tests (#30580)
  feat: Save visitor's activity on agent's interaction (#30222)
  chore: update mentions upsell modal content (#30503)
  fix: font-disabled color (#30569)
  chore: anchor text-decoration rules (#30485)
  ...
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