I've tried multithreading with php, wrote a simple script which checks a series of ip addresses and tries to ftp into them.

I've noticed that the script is running very slow, i checked everything, tested the db, tested my code, i've started to doubt, that my compilation of php was fucked up (btw i did that for the first time).

Then i've started to mesure the time of each db request, but the numbers didn't add up. Then it fucking hit me...

I fucking set the timeout for ftp_connect to 5 seconds, and that was causing the slowdown. I wasted two fucking coding sessions on finding that out.

What a fucking blind moron can I be, holy shit.

  • 6
    Don't be so hard on yourself. Everyone is making dumb mistakes, juniors, seniors..everyone.. Just make sure you don't lose passion for hunting them down..
  • 2
    This is why I switched from to C#. I used php since it was php4 and early php5.

    PHP is good for generating text, which is the web/HTML, anything other than that, it doesn't do well.

    Sounds like you are interested in proper programming rather than just to go to the database and print out some text.

    Make the switch.

    A proper IDE can tell you where the CPU time goes in a few clicks.

    I had a look at php7 the other day cus I heard it is better. Nope. It is not.
  • 1
    Sometimes you just need scripts instead of what you call "proper" language. Just saying.
  • 2
    @nam17887 Disagree. (The part that its only good for html/web)

    I write nearly all my software (web services, api's, cli tools etc) in php.

    Currently working on a monitoring system and it works great with ssh!
Add Comment