Hello everyone,
In my setup, I am loading PJSIP objects using Dynamic Realtime. Below is an extract of sorcery.conf, most other object mappings follow the same pattern;
endpoint/cache = memory_cache,object_lifetime_stale=3600,object_lifetime_maximum=7200
endpoint=config,pjsip.conf,criteria=type=endpoint
endpoint=realtime,ps_endpoints
From SQL query log files, I noticed that each time I reload Asterisk, a generic select statement is done to get all endpoints, followed by a select for each endpoint;
2021-06-04T16:31:28.753244Z 46452 Prepare SELECT * FROM ps_endpoints WHERE id LIKE ? ORDER BY id
2021-06-04T16:31:28.796128Z 46452 Execute SELECT * FROM ps_endpoints WHERE id LIKE ‘%’ ORDER BY id
2021-06-04T16:31:28.837927Z 46452 Close stmt
2021-06-04T16:31:28.879978Z 46452 Prepare SELECT * FROM ps_endpoints WHERE id LIKE ? ORDER BY id
2021-06-04T16:31:28.921308Z 46452 Execute SELECT * FROM ps_endpoints WHERE id LIKE ‘%’ ORDER BY id
2021-06-04T16:31:28.963048Z 46452 Close stmt
2021-06-04T16:31:29.030092Z 46452 Prepare SELECT * FROM ps_endpoints WHERE mailboxes != ? ORDER BY mailboxes
2021-06-04T16:31:29.074673Z 46452 Execute SELECT * FROM ps_endpoints WHERE mailboxes != ‘’ ORDER BY mailboxes
2021-06-04T16:31:29.114880Z 46452 Close stmt
2021-06-04T16:31:29.165775Z 46452 Prepare SELECT * FROM ps_endpoints WHERE id LIKE ? ORDER BY id
2021-06-04T16:31:29.206509Z 46452 Execute SELECT * FROM ps_endpoints WHERE id LIKE ‘%’ ORDER BY id
2021-06-04T16:31:29.248157Z 46452 Close stmt
2021-06-04T16:31:29.288719Z 46452 Prepare SELECT * FROM ps_endpoints WHERE id = ?
2021-06-04T16:31:29.329333Z 46452 Execute SELECT * FROM ps_endpoints WHERE id = ‘boardroom@arkafort.com’
2021-06-04T16:31:29.370251Z 46452 Close stmt
My database is about 30ms away. I have around 300 endpoints at the moment and starting up asterisk takes about 45 seconds. Im planning to have about 3500 endpoints on the server, which would result in a startup time of around 8 to 10 minutes. Not to mention concerns on the database side of things.
Is this expected behaviour or can I in some way optimize this?
Thanking you in advance for your time and consideration.
Regards,
Gordon