Short Video Distribution System Build Log: uniapp + ThinkPHP + Workerman Recommendation Engine
Short Video Distribution System Build Log: uniapp + ThinkPHP + Workerman Recommendation Engine
Disclaimer: This article is for technical education and demonstration only. It is not professional or financial advice. Any real-world deployment must comply with applicable laws and regulations.
I recently helped a client deploy a short video content distribution system. The frontend is built with uniapp, the backend uses ThinkPHP, and Workerman handles long-lived connections and the real-time recommendation feed. The whole setup runs on a single entry-level server. With 80 users watching videos simultaneously across 28 content channels, the CPU stays stable. I am writing down the pitfalls I hit so other people building content platforms can reference them.

Feature Test: Recommendation Feed, Publishing, and Earnings Settlement All Work
The admin panel is a unified control center. It can create content categories, configure recommendation weights, and view simulated creator earnings. The core is a recommendation algorithm: it scores content based on user dwell time, likes, and completion rate, then distributes content with a heat-weighted ranking.
The Real-Time Recommendation Feed Is the Main Highlight
The system connects to three content-platform interfaces: reading creator account data, a content publishing interface, and a real-time video stream / recommendation event interface. The real-time interface is a websocket data stream, pushing anywhere from a few messages to about thirty per second, depending heavily on the channel.
On the backend, Workerman’s AsyncTcpConnection receives the websocket stream. It accesses wss with transport=ssl, decompresses encrypted data with gzdecode, and decodes the payload with json_decode. If the connection drops, reConnect handles automatic reconnection, so manual intervention is rarely needed.

Scheduled Jobs Run in Resident Memory with the Timer
Recommendation leaderboards, content moderation, and settlement rankings all use Workerman’s built-in Timer, executed by PHP-CLI in resident memory. This avoids complicated caching and async queues, so a 2-core 4GB machine can still handle the concurrency.
Payments and Settlement
By default, the platform supports automatic creator earnings posting. Withdrawal requests go through manual admin review, but you can switch to automatic mode. The recharge module can connect to platform points or third-party fiat payment channels, and the admin panel can toggle between them with one click.

Real-time recommendation feed parsing, websocket reconnection, and PHP-CLI resident-memory timers are the combination that lets a low-spec server run a content platform.
Deployment Notes: Environment, Ports, and SSL Cannot Be Skipped
The server is running CentOS 7.2 with a 2-core CPU, 4GB of memory, and a 2MB bandwidth link. The uniapp project is packaged for H5 and mini-programs, ThinkPHP runs on PHP 7.3 or higher, and Workerman requires the pcntl and posix extensions and must be started from the command line.
Websocket and SSL
If the site uses HTTPS, wss must have a certificate configured. When using transport=ssl, check that the certificate chain is complete, otherwise AsyncTcpConnection will throw a handshake failure. During debugging you can run ws first, then switch to wss before going live.
Database and Admin Panel
MySQL 5.7 is sufficient. Categories, tags, and recommendation weights in the admin panel can all be changed dynamically. I recommend adding indexes on category_id, status, and create_time in the content table, or queries will lag once the number of channels grows. In practice, the admin panel slowed noticeably when we opened 43 channels, but became smooth again after reducing to 28.
Target Audience and Secondary Development Directions
This system is suitable for short-video communities, vertical content distribution, and creator incentive platforms. For secondary development, you can add multilingual support (uniapp’s built-in i18n is convenient), connect more content sources, or upgrade the recommendation algorithm to collaborative filtering.
FAQ
Q: What if the real-time recommendation feed freezes?
A: First check whether the Workerman process is still alive, then inspect the wss handshake and gzip decompression. Also avoid opening too many channels at once; on low-spec machines, keep it under 30.
Q: Can the uniapp mini-program client be used directly?
A: H5 and App work out of the box. For mini-programs, you must configure legal domains, and the wss domain must be added to the mini-program backend server domain list.
Q: Can withdrawal review be switched to automatic?
A: The admin panel has an automatic/manual switch, but automatic payouts require you to configure the payment channel keys first. I recommend running it through the test environment before enabling it in production.

This article is for technical education only. The system is a technical demonstration; please comply with relevant laws and regulations and do not use it for any illegal or non-compliant purposes.
Disclaimer: This article is for technical education and demonstration only. It is not professional or financial advice. Any real-world deployment must comply with applicable laws and regulations.
#short video #uniapp #ThinkPHP #Workerman #recommendation algorithm