32
Comments
  • 6
    Php is coool man
  • 3
    I don’t, I’m native baby!

    PHP is awesome fun, today I implemented mass async cURL which will bring blocking time down by 75% (or in other words, this damn automated process won’t take an hour to run anymore)

    Tell me again how it’s not fun?
  • 3
    @C0D4 PHP? Async?

    YOU JUST BROKE THE MATRIX!
  • 7
    @C0D4 having to use curl to make script run async is itself a sign of bad design. Java has Future<>s, node has promises, even bash can do this with nohup and &. Yet you are using PHP calling curl to parallelize the execution. Amazing. The word "fun" you wrote has so much "i have masochistic fetish" inside!
  • 3
    @mt3o You can also call another PHP instance using bash but... it's like shooting yourself in the foot.
  • 2
    @jAsE-Official exactly. That's the reason long running tasks should never be made with php.
  • 0
    Frameworks make my life easier and I'm just now learning about them. Why would you give this advice?
  • 1
    @samsepiol Sometimes frameworks can also overcomplicate things. Just use frameworks wisely.
  • 2
    There is one more reason against using php as async with the help of curl. If we have 4 execution threads and one governing them, the machine has to reserve 5 php-fpm processes. My hosting company allows me to use up to 20 php-fpm processes. So that's 25% of all allowable capabilities. Quite much! On the other hand, languages that provide native async support handle things in the same execution loop (node) or as lightweight threads (java). Bash has totally different approach, because there each command is a separate process. But it doesn't have to be responsive in any way during the execution.
  • 0
    @mt3o not quite.

    It’s having to use cURL to call multiple APis around 10k times, to then be able to extract the necessary data needed to then apply the business logic.

    Would be nice if these APIs allowed for bulk querying but nope - and no I don’t own these APis otherwise I would just change em.

    So without adding the multi thread version of PHP to this server, using cURL in async and making ~100 concurrent requests is a much simpler and faster process.

    Granted futures would be great here, but this isn’t Java.
  • 0
    @mt3o this is a dedicated on prem sever, I can bust its balls and not be concerned.
  • 0
    @jAsE-Official time for a reboot!
  • 0
    You, of course, tried using pthread and other approaches to threading in php? Backticks, calling native os commands?
  • 1
    @mt3o PHP curl module has built-in async support.

    And yes, I love php.
  • 0
    @linuxxx is this something implemented after 5.3?
  • 0
    @mt3o I'm using it with PHP 7.2 right now :)
Your Job Suck?
Get a Better Job
Add Comment