To many Entry Processes

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
R Scott
Posts: 14
Joined: 2018-01-04 18:42

To many Entry Processes

Post by R Scott » 2021-03-22 14:52

I am using AppGini for a classroom environment. Ocassionally my hosting platform will give me an error of "Resource Limit ReachedError 508" to many entry processes and said that I need to optimize my code. Any suggestions ? I am not sure what an entry process is or how to optimize. This error happens when about 60 people try to login during a short time frame.

Thanks

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: To many Entry Processes

Post by onoehring » 2021-03-23 06:37

Hi,

the error you are describing is a MySQL notification (well, "error" is you want), see https://stackoverflow.com/questions/309 ... -php-mysql

I had a similar (the same) problem: Requests for the database (reload of pages, search etc.) did not go through: The page "froze" for about a minute. In my case however I did not even see an error, I needed to trap if first.
Analyzing the problem, I came to the conclusion, that this was because of too many concurrent requests to the database. Each connection is kept open for 60 seconds if not properly closed. This is done to make more requests using the same connection faster (as there is no need to reopen a database connection, this time could be saved).
I called the webshoster (1&1) and they confirmed that on shared hosts only X (50 or less, I can not remember, another hoster has only 18) concurrent connections to the database are possible.
I then did add the code below to the /hooks/footer-extras.php as the very last lines of code in that file. Since then no more problems (I admit, that there might be other reasons, but this change was the change I explicitly introduced for this problem

This code closes the current database connection - so that others can be reopened. If the connection can not be closed, it should show an error.

Code I inserted in hooks/footer-extras.php.

Code: Select all

//START Close DB
$con = db_link();
if (db_close(db_link())) {
	//close ok, nothing else to do here
} else {
	echo "db_close failed";
}
//END Close DB
Please let us know, if this solves your problem.

Olaf

R Scott
Posts: 14
Joined: 2018-01-04 18:42

Re: To many Entry Processes

Post by R Scott » 2021-03-23 11:56

Thanks for the quick response, I will add this and monitor the process load today.

R Scott
Posts: 14
Joined: 2018-01-04 18:42

Re: To many Entry Processes

Post by R Scott » 2021-03-25 14:54

Unfortunately this did not help. I received the same error again today with only 25 users logged in. Is there any way to see in real time what entry processes are happening? I do not clearly understand what an entry process is or how to track down the load issue. Should my next option be to pay for a larger hosting package that allows more than 20 process?

Thanks
Richard

R Scott
Posts: 14
Joined: 2018-01-04 18:42

Re: To many Entry Processes

Post by R Scott » 2021-03-25 16:55

update: the file that is being accessed to frequently is ajax_check_login.php

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: To many Entry Processes

Post by onoehring » 2021-03-25 19:23

Hi Scott,

I doubt, that getting a larger hosting package will solve the problem - as even large providers put a limit on the concurrent database connections. Maybe your own root server might help - but I actually doubt this as well.
It seems strange to me, that the error occurs again and again - even when you use the code about to close the connections once "done". The file pulls the username, obviously to show it in the top right hand corner for the logged in user. So, once the page has been generated, the connection used by THAT user should be closed by the code above. There could probably a little bit of delay if all 25 users log in at the same time, but why this should be badly noticeable I can not get my head around.

Did you contact your hosting company and ask them about the limits for concurrent mysql connections?
Probably you do not have permissions to allow more connections at a time, but you can check out these links for example on how to do this. You would need to include some SQL code into ... (some file) to adjust the max connections ... but as I said, probably you do not have the permissions (from your hoster) to do so. Links:
https://stackoverflow.com/questions/222 ... onnections
https://tecadmin.net/check-update-max-c ... lue-mysql/
https://electrictoolbox.com/update-max- ... ons-mysql/
https://bluemedora.com/mysql-performanc ... nnections/
https://bobcares.com/blog/mysql-max_con ... d-maximum/
and of course MySQL docs: https://dev.mysql.com/doc/refman/8.0/en ... tions.html

Search string: https://duckduckgo.com/?q=mysql+max-connections

Olaf

R Scott
Posts: 14
Joined: 2018-01-04 18:42

Re: To many Entry Processes

Post by R Scott » 2021-04-01 15:05

UPDATE:

I received the following email from my hosting company about the entry process limit errors. any thought?
much of this is out of the scope of my skill level but i will start researching.


---------------
Per our check, your EU usage is critical.

In this case, we would like to advise you to resolve your issue with EU usage.

It has come to our attention that the 'membership_users' table of the 'starefbo_missionlog2020' database gets locked too often. We suggest converting this table to the InnoDB database engine. You may use this guide as a reference: https://richardcummings.info/convert-my ... hpmyadmin/ .

At the moment, you have the MyISAM database engine for your table - that means that each time this table gets updated, it gets locked and other DB queries should wait till the table gets unlocked. After converting your table to InnoDB, all database queries to this table will not have to wait till the table gets unlocked because, unlike MyISAM, InnoDB has row-level locking.

As a result, the web requests will not get stacked due to the frozen DB queries and the requests will get processed significantly quicker.
-----------------

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: To many Entry Processes

Post by onoehring » 2021-04-02 07:45

Hi,

well, your hosting explained it nicely: They seem to have looked at your database.
MySQL is the databasemanagementsystem which can hold different databases. Each table (in each database) has it's own "format". Currently your tables seems to be using the (old) "MyISAM" format. As your hosting company described, it's better to use the "InnoDB" format (which btw. in my AG applications is the default for all tables ... strange, that it's different in your case).
If you are using the tool adminer ( https://www.adminer.org/ ) for administration of your database it should look like this:
f1.png
f1.png (48.94 KiB) Viewed 2710 times
The link your company provided the person is trying to use phpmyadmin (similar to adminer) to convert tables into InnoDB in a "graphical" way. When you scroll down to the comments of that blog post. The first commentor (Paul) suggests using simple SQL queries. In adminer you can use "SQL Command" to run such commands.
f2.png
f2.png (23.39 KiB) Viewed 2710 times
Paul suggests

Code: Select all

ALTER TABLE `Events` ENGINE=InnoDB;
This would convert the table Events in the current database to the InnoDB format. You would need to use a similar command for each and every single table in your AG application to convert tables one after another. You may be able to use an editor to create single SQL queries. Note: Each query ends with a ";"!

If you do not want to go one by one, you can use suggestions provided here https://www.ryadel.com/en/mysql-convert ... or-innodb/ and https://stackoverflow.com/questions/385 ... nto-innodb (note: be careful, read comments. Probably the post with 581 "likes" is the most useful: https://stackoverflow.com/a/9492183 )

Warning: Backup your database before any actions! Don't blame anyone if you mess something up.

Olaf

R Scott
Posts: 14
Joined: 2018-01-04 18:42

Re: To many Entry Processes

Post by R Scott » 2021-04-12 01:40

Just a quick follow up to say the above changes have solved the entry process problems. I am not sure why the default format was set to MyISAM instead of the more robust InnoDB. I used the setup script from appgini and never checked the formats. Thanks for the feedback, this forum has been a huge help in creating my project.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: To many Entry Processes

Post by onoehring » 2021-04-12 12:44

Hi,

you are very welcome - and so is your follow up. Thanks for letting us know.

Olaf

Post Reply