WhatsApp / WhatsApp-Business-API-Setup-Scripts

The scripts related to setting up WhatsApp business API
MIT License
410 stars 433 forks source link

WA_DB_CONNECTION_IDLE_TIMEOUT what is recommended value? #32

Closed Goodsmileduck closed 4 years ago

Goodsmileduck commented 4 years ago

On https://developers.facebook.com/docs/whatsapp/changelog I still see

Ability to close idle MYSQL DB connections using WA_DB_CONNECTION_IDLE_TIMEOUT (in seconds)

On https://developers.facebook.com/docs/whatsapp/guides/mysql

WA_DB_CONNECTION_IDLE_TIMEOUT — By setting this environment variable (in milliseconds) while starting the Coreapp, you can set the idle timeout for your MySQL database. The MySQL server will then close any database connections that are idle for the time set.

Meanwhile, in docker-compose config you have value 180000 https://github.com/WhatsApp/WhatsApp-Business-API-Setup-Scripts/blob/master/installation/db.env#L11

  1. So what is a measure for that variable?
  2. What is the recommended value?
  3. Is it different for different app versions?
  4. Only for coreapp containers?

https://github.com/WhatsApp/WhatsApp-Business-API-Setup-Scripts/blob/0a932af7ef166294a7ca8f816fbd2f65761f8ad4/installation/kubernetes/db.env#L11

mengyiyuan commented 4 years ago

@Goodsmileduck Thanks for reporting the discrepancy in the docs! Let me check with the team to confirm. Will reply once I have the answer.

mengyiyuan commented 4 years ago

@Goodsmileduck

The variable should be set with the measure of milliseconds. Some context about this complexity: Before v2.27.11, which includes v2.27.8 where you quoted the Changelog from, there was a bug in this variable that we later fixed.

From v2.27.11 onwards, you should set the value to be milliseconds to have the correct behavior.

For high throughput, we currently recommend to set it as 180000 (180s) as documented https://developers.facebook.com/docs/whatsapp/guides/high-throughput. I will update the value in k8s setup shortly.

Currently this variable is only supported by coreapps.

Goodsmileduck commented 4 years ago

So for v2.27.8 we should set it to 180 After v2.27.11 need to set 180000 right?

mengyiyuan commented 4 years ago

So for v2.27.8 we should set it to 180 After v2.27.11 need to set 180000 right?

My understanding is that for versions before v2.27.11 (not inclusive), the value will be misinterpreted by one of the DB modules we used (which was the bug) as milliseconds and interpreted as seconds in all other modules, the behavior may be unexpected. You don't have to set this value if you have a particular reason (seeing related errors) or I suggest upgrading to v2.27.11 or later.

Goodsmileduck commented 4 years ago

Got it. Thank you for clarify!