OfficeDev / teams-toolkit

Developer tools for building Teams apps
Other
468 stars 193 forks source link

As custom storage grows, the bot response is getting slow #10089

Closed iloveyeseul closed 11 months ago

iloveyeseul commented 1 year ago

Describe the bug Our team built a bot which is sending proactive messages to users. We implemented the bot with Azure functions, bot framework, Teamsfx toolkits and azure blob storage to store conversation references permanently. We followed this official documentation on implementing custom storage: Notification bot in Teams - Teams | Microsoft Learn

We also followed this sample codes to implement the custom blob storage: TeamsFx-Samples/adaptive-card-notification/src/store/blobStore.ts at v3 · OfficeDev/TeamsFx-Samples (github.com).

However, when the blob storage conversation grows only 85 blobs, the bot http response is getting really slow from 700ms -> 1 min 30sec. We would like to know why this is happen and what is possibly related to this issue. We are targeting more than 50K users to intall the app, so this slowness is a big issue.

Main API we use notificationApp.notification.findMember member.sendAdaptiveCard

To Reproduce Steps to reproduce the behavior:

  1. Blobs added to azure blob container
  2. Bot sending messages is getting really slow

Expected behavior Bot should support the many load and look up conversation references efficiently

Screenshots If applicable, add screenshots to help explain your problem.

VS Code Extension Information (please complete the following information):

CLI Information (please complete the following information):

Additional context Add any other context about the problem here.

yiqing-zhao commented 1 year ago

Hi @iloveyeseul, the delayed response is due to the bot’s process of retrieving installations. In this process, the TeamsFx SDK validates each installation, leading to a longer response time. You can refer to the validation code for more details.

By default, this validation is active. However, you have the option to disable it, as demonstrated in the following line (by adding false). Please ensure that your TeamsFx SDK (@microsoft/teamsfx) is updated to the most recent version 2.3.0 to utilize the disable feature.

const pagedInstallations = await notificationApp.notification.getPagedInstallations(pageSize, continuationToken, false);

In addition, we are preparing to onboard a large-scale notification bot shortly, https://github.com/OfficeDev/TeamsFx-Samples/pull/1014. Hope this will help you out.

tinsheep commented 7 months ago

Hi @yiqing-zhao or all - i have a similar issue but it is with the findChannel. Does the updated version help with performance of findChannel? Doesn't look like there is any validation checking in there. We do have some large teams (80+ channels) which is perhaps why it it taking so long? I have the bot installed in the general channel and being that is the recommendation why it would need to go through every one? Any guidance how I might improve performance of findChannel so that I can send an adaptive card to it? thanks!