Matomo multi-instance setup issue: Communication problem between nodes with shared database

Hi, could you kindly assist me in solving this problem:
I’ve got two separate ec2 nodes running two separate instances of matomo, each of which is connected to the same database. The first node will communicate with the database to perform any action or load a page, but the other will immediately log out because they are connected to different prefex tables.
I tried to change the storage mechanism to memcached for both instances, but it didn’t work. I established a new database with a new user for one of the Matomo instances, and I recreated its installation. fails to work