NEXJTS SSR AWS Amplify - Production env is slow on load

Viewed 17

My Nextjs SSR App on AWS Amplify is too slow:

The same app on local pc started with commands yarn build && yarn start it is fast enough but on aws:

  • First page load: 10.43 Sec
  • When click on a link in the page: 9.5 Sec

The getServerSideProps() doesn't call 999 API but just retrieve user data from cognito :

export async function getServerSideProps(context) {
  let req = context.req;
  const { Auth } = withSSRContext({ req });
  try {
    let user = await Auth.currentAuthenticatedUser();
    return {
      props: {
        param1: context.params.param1,
        param2: context.params.param2,
        user: user,
        ...(await serverSideTranslations(context.locale, ["common", "dashboard", "footer","fs"])),
      },
    };
  } catch (err) {
    return {
      redirect: {
        permanent: false,
        destination: "/auth/signin",
      },
      props: {},
    };
  }
}

After the first time click page, the same page (with other params) it's faster (~2.1 sec)... I tried to enable "amplify performance mode" that it should lengthen the time of caching but no real improvement. How can I fixed that?

0 Answers
Related