Best practices for PHP 8.2 backend integration with RouterOS for dynamic queue & session management

Hello everyone,

I am currently working on a custom web platform built with PHP 8.2 and MySQL to manage internet users, IP/MAC bindings, and dynamic bandwidth queues via MikroTik RouterOS.

The core challenge I am facing is designing a scalable and efficient synchronization mechanism between the PHP backend and the router without causing high CPU overhead or connection bottlenecks on RouterOS during peak hours. Specifically, I am trying to figure out:

  1. What is the most efficient method for a PHP backend to handle real-time user session authentication and dynamic queue creation (e.g., using RouterOS API, SSH commands, or a local daemon)?
  2. How to properly manage IP bindings and active user states in the database while keeping the router's resource utilization minimal.
  3. Best practices to handle database-driven session timeouts and automatic removal of expired queues.

Any advice, architectural patterns, or recommended libraries for PHP-RouterOS communication would be greatly appreciated. Thank you!

Hi!

I am not a developer, so unfortunately I cannot help you with your specific questions. But I am an operator responsible for more than a thousand customer hosting instances most of which run PHP.

So I'd like to advise you to switch to a later PHP version right now, before even starting. PHP 8.2 is already in limited support state receiving only security fixes. And that will end come 2027, too. Don't run outdated unsupported and known insecure software, please.

See https://www.php.net/supported-versions.php for reference.

Kind regards,

Patrick

My suggestion would be to use RADIUS if at all possible. It was made for basically this exact use case.

If it's not possible, use either the native or REST API. In my experience both have normal performance. The only architectural consideration is to implement a single process synchronizer instead of configuring things in-line.

Hello everyone,

I am currently developing a custom ISP management platform using PHP 8.2, MySQL, and MikroTik RouterOS. The platform manages internet users, IP/MAC bindings, user authentication, and dynamically creates bandwidth queues based on database records.

My primary challenge is designing a synchronization mechanism between the PHP backend and the MikroTik router that remains scalable, efficient, and minimizes CPU and connection overhead, especially during peak usage.

I would appreciate advice on the following:

  • Real-time synchronization: What is the most efficient approach for handling user authentication and dynamic queue management? Is it better to use the RouterOS API, SSH, or a dedicated local daemon/service that communicates with the router?

  • IP/MAC bindings and active sessions: What are the best practices for maintaining IP bindings and tracking active user sessions in the database while minimizing RouterOS resource utilization?

  • Queue lifecycle management: How should expired sessions and bandwidth queues be handled? Is it better to let the PHP application periodically synchronize changes, or should RouterOS scripts and schedulers be used for automatic cleanup?

  • Scalable architecture: For deployments with thousands of users, what architecture has proven to be the most reliable? For example, should the web application only update the database while a background worker synchronizes changes with RouterOS, rather than having every web request communicate directly with the router?

From my research, it seems that avoiding frequent API calls from the web application and instead using a background synchronization service or daemon to batch updates may provide better performance and significantly reduce RouterOS CPU usage. However, I would like to hear from those who have implemented similar systems in production.

Additionally, if there are any recommended PHP libraries (such as the PEAR2 RouterOS library or other actively maintained alternatives) or architectural patterns for large-scale MikroTik deployments, I would greatly appreciate your recommendations.

Thank you in advance for your insights and experience!

Strange Programming of Dr @NabilM2026 and Mr @michaeld ?

Splitted personality? Ctrl+C/Ctrl+V stuck?

What's going on?

Runaway AI?