Menu

Rebuilding a Node.js downloader in plain PHP: what shared hosting forced me to rewrite
πŸ“°

Rebuilding a Node.js downloader in plain PHP: what shared hosting forced me to rewrite

DEV Community: phpΒ·Mobeen AhmedΒ·6 days ago
#IHyktP6Y
#devto#dev#file#node#memory
Reading 0:00
15s threshold

I built my video downloader in Node.js first. It worked on my laptop, it worked in my tests, and it fell over the moment I tried to put it on the hosting I had already paid for. My Hostinger Premium plan does not run Node.js at all. There is no process manager, no long-running server, no port I can listen on. What it does run is PHP, so I had a choice: pay for different hosting, or rebuild the whole thing in plain PHP. I rebuilt it.

The first thing that changed was the mental model. A Node app is a process that stays alive and waits for requests. PHP on shared hosting is the opposite: a script starts, handles one request, and dies. There is no memory between requests unless you write it to a file or a database. So everything that used to live in memory β€” the rate limiter, the little cache of recent provider responses, the retry state β€” had to be rethought.

The rate limiter was the most instructive part. In Node I kept a map of IP addresses to timestamps in memory and trimmed it on every request.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.