Matomo keep on fluctuating with in 2 weeks

Hello, We have Matomo running with 3.12.0 version with MySQL DB in different server from AWS. But from Last 3 months for every 2 weeks RDS alerts reached high, RDS CPU reached 100 %, then we were not able to login even server also application went down.
When i try to restart server from console manually then it came up. But it keep on fluctuating. when i went through the logs, i saw errors relates to MySQL. Then i come to know that “max_allocated_package” has been changed. I have couple of questions on this.

  1. Where exactly we can add this value to reflect for application. Earlier we added in the RDS parameter group. But now that value is not fetching from that. To change /etc/my.conf we have not configured in this way.
  2. How we can finalize page views for all websites to decide on the server configurations. Based on which parameters we can decide either app server & DB.
    Errors: [php7:notice] [pid 4727] [client 172.16.86.0:54498] Error in Matomo (tracker): SQLSTATE[HY000] [2006] MySQL server has gone away,
    [php7:notice] [pid 4229] [client 172.16.64.33:19116] Error in Matomo: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away - in plugin Goals, referer:

Thanks & Best Regards
Revathi