About Amity SDK taking long time to load

We’re implementing Amity Follow on our web.
We want to show whole following lists on the sidebar.
image

And there’s another seciton called Suggested Creator which we’ll need to pass whole following lists to our api for not showing creator that user is following on this section.

Here are the steps that we implemented

  1. When our system can detect logged in user, our system will use userId to register with registerSession.
  2. Do nothing until registerSession finished (After we got status “connected” from connectionStatusChanged)
  3. After we got “connected” status, we’ll get follow list with UserRepository.getFollowers, get follow status with UserRepository.getFollowInfo

Then we found that It take quite long time to show the followList, followStatus.
So we tried to log how long does it take for each steps.

Seem like

  • it took around 1.5 sec since calling registerSession until we get status “connected”
  • it took around 2.6 sec since calling UserRepository.getFollowers until we get data from “dataUpdated” event
  • it took around 2.7 sec since calling UserRepository.getFollowInfo until we get data from “dataUpdated” event

image

So I have some questions.

  • Is this normal load time?
  • Is there a way to decease the loading time?
  • Or do you have any ideas why it take this long?

Hi @tlezip ,

registerSession normally takes less than 500ms to complete - so the duration you shared isn’t normal. Can you help share the code where you’re calling and logging to console?

You also shouldn’t be using getFollowInfo unless you’re particularly checking for follow status of a user?

This is how we registerSession
In the page, we call this useAmity, and in useAmity It’ll have useEffect

And this is code inside useAmity

You also shouldn’t be using getFollowInfo unless you’re particularly checking for follow status of a user?

We’re checking for follow status for each suggested creator. When user click on follow button, then the status on the button should change to following.

Since it’s web sdk can you also help share HAR file (instruction here:

Hi

Some additional information about the slowness:

I’ve tried out Follow & Unfollow requests using Postman. The responses are quite slow.

POST - https://api.sg.amity.co/api/v4/me/following/100233008
About 3 seconds

DELETE - https://api.sg.amity.co/api/v4/me/following/100233008
About 2 seconds

Is this normal?

This is HAR file that I got from running on local

I’ve uploaded har file here

From your HAR packet registerSession is completed within around 200 ms + another 1 second to establish websocket connection, which looks normal.

However I do see that you’re calling 21 calls at the same time after that to get follow info of each person’s relationship - and another batch right after. This could be something that will slow your response down + will be at risk of hitting rate limit – you may need to throttle this down while showing less users on the suggestion list.

Another suggestion would be to do a lazy loading and put in spinner while each follow info is loading

@touchaponk We made some changes into our code. We managed to remove the unnecessary followInfo calls.

However, the problem mentioned in my previous comment is still a mystery. When user clicks Follow button, it takes about 3-4 seconds before SDK responds. I see the same slowness when I call the follow API endpoint using Postman.

Are these response times normal? Is there something that could be done to make the API respond faster? I have a memory that the API was working much faster about 1-2 months ago.

Hi @Juho - could you DM me your API Key and exact curl command so I can check them with the engineer?