« first day (1946 days earlier)      last day (2999 days later) » 

6:00 PM
@Wes hehehe
 
@FlorianMargaine And apache will just happily load the whole post data in memory and fail at a certain fixed limit then.
Also, Aerys does allow for writing a webpush extension to it for example … nothing you can do with mod_php...
and there are the limits of PSR-7
 
@bwoebi sure, but I didn't see how that was related to PSR-7
 
PSR-7 wouldn't allow for these things either and I can badly have a Promise + a all data available interface
either the data is all available when I start the handler or it isn't and I anyway need a promise.
 
yeah, I get that PSR-7 is incompatible with promises, my bad
 
you can build your custom wrapper $serverInterface = yield wrap($request); if you need that
 
6:06 PM
aren't PSR7 request bodies streams? a call to the stream's read could wait for the promise
or are headers also set from within the promise?
 
@Caleb it could wait … and block the whole server… this isn't threads, it's async I/O ;-)
@Caleb no, headers are already available at handler call.
 
right but I was planning on thread per request
receive a request, then start a thread that converts to the PSR7 object and passes that to Yii2
 
sure, you'll just have to pipe the data forward in an I/O handler, then you can properly build that together in a separate thread
yes, that would work
 
awesome. can I use an output buffer callback in the thread to write the response
 
@FlorianMargaine Another point where we see why it's modeled to php web SAPI, is the stream interface supposed to take advantage of php://input
@Caleb if you stream that back to the handler, yes.
 
6:11 PM
@Caleb Why do you want to do what you want to do?
 
not 100% sure either :-D
 
I want shared memory objects that live from request to request
 
@Caleb Is this a performance optimization?
 
@Caleb then I don't know why you want to couple that to Yii.
 
my app is a Yii2 web app
each request loads a lot of database rows into ActiveRecord objests, each subsequent request loads the same objects
the majority of time spent in every request is loading these objects from the database. Synchronizing with Redis or Memcached seems like a lot of wasted IO
 
6:17 PM
@Caleb If I was going to architect a solution for that I would have a background task that runs continuously, and holds all those objects in memory, and the front-end would communicate with that background task via sockets or redis.
You almost certainly don't need to pass a complete HTTP request through to the thing that is holding all of the ActiveRecord objects in memory.
 
well, you could try to json_encode headers + wait for the body and send that data then to a worker process (if you want to retain Yii and not completely rearchitecture your App)
 
You just need to pass an internal API request, which doesn't need to have anything to do with HTTP.
 
but as Danack says, rearchitecturing is the best way to go … using workers is rather a hack ^^
if your app is small, choose the first way, else (if you don't have too much time to rewrite much), the latter.
 
Is running an HTTP Server from the PHP CLI inherently slower than FastCGI or something?
 
no.
it's slower if you just stay in blocking fashion and don't handle concurrency at all
(e.g. threads, event loop, forks)
ah, the good old days of cgi.
 
6:25 PM
right, but if you run a thread per request, and implement RW mutexes on shared data, shouldn't it be faster than running a separate process? plus you don't have to maintain an API to the separate process holding data
 
@FlorianMargaine good old days? :-P
 
@bwoebi ... fair enough.
 
I see a huge benefit in being able to interact with the objects in native PHP
 
@Caleb as long as your application won't horribly break whenever you're going to scale out to two servers…
 
oh joy
 
6:28 PM
\o/ yay online in new home
 
a Yii user
 
happy caturday!
 
@tereško haha … at least no codeigniter
 
The overarching router implements session affinity based on job
 
@RonniSkansing do you have optic?
 
6:29 PM
nope
 
Requests for shared data will always go to the same server
 
but I dont need it.. =)
 
@bwoebi ya know, CodeIgniter doesn't come with jquery and active record
 
@Caleb And you think that's a good idea?
 
@Sherif why wouldn't it be?
 
6:30 PM
@Caleb Think about it for a second. What happens when requests for the same data increase?
 
@Sherif many load balancers support putting the server in the cookie so that a user will remain on the same server
 
@Sherif
 
(usually for bad applications that don't know how to use e.g. redis to manage sessions.)
 
@FlorianMargaine Right, and that's a poor architecture design.
 
@Sherif there will only be around 5 users in a job at a time
 
6:31 PM
It doesn't lend itself well to scaling horizontally.
 
31 secs ago, by Florian Margaine
(usually for bad applications that don't know how to use e.g. redis to manage sessions.)
 
@Caleb Session affinity is the kind of thing that comes back to bite you when you try to scale wide.
 
also, having a distributed filesystem across your fleet (to handle e.g. a temporary file across multiple requests) can be daunting to install
 
Just don't say I didn't warn you.
 
@FlorianMargaine so … making more requests with a fixed cookie will immediately DoS a certain server?
 
6:33 PM
@bwoebi yes. You have to figure out the cookie though.
 
@bwoebi it's a really good way to to it too
local superiority at it's best
 
iirc, the load balancers put a "session id" for the server, so it's not a cookie valid all the time
they may even reuse the session cookie that the application uses.
 
@FlorianMargaine but that still sounds very dangerous though…
 
and if you can have a session cookie stolen, you have other things to worry about than one of your servers being DDoSed :)
 
Is it just me or does anyone else find this kind of thinking bizarre and rampant now a days. All these young engineers with their "Hey Active Record stores all this data and it's expensive... I know the solution!!!! I'll make PHP persistent outside the request life cycle! What could possibly go wrong?!?!"
 
6:37 PM
@Caleb ftr, personally I'd optimize my sql queries.
 
@Sherif it's bizarre that they can call themselves engineers …
 
@Sherif that's the problem when you're a "devops", that doesn't work :(
 
@bwoebi You know the problem with school is they teach how to solve problems. They just don't tell you which problems are probably worth solving...
I guess sometimes ignorance really is bliss.
 
@Sherif until you're responsible when everything collapses.
 
So instead of pulling a response from Memory where it's readily available, let's go back to the Database every single time?
 
6:39 PM
@Caleb yes.
 
@Caleb Memcached is in memory. Why can't you use that?
 
@Caleb yes. You can cache certain things locally in a Redis or Memcached in-memory storage, but yes, go refetch.
 
this is where things like ActiveRecord suddenly start looking very bad.
 
Doing I/O to a backend process is just as expensive as requesting data from a local Redis storage.
 
And doing thread synchronization is faster
 
6:41 PM
 
What threads? The PHP runtime is not threaded.
 
Pthreads
 
@Caleb that's optimizing on the wrong end … seriously. It's so little faster in comparison to everything else that it just doesn't matter.
 
That's not the PHP runtime
You seem deeply oblivious about which problem you're trying to solve right now.
 
@Sherif ext/pthreads ? or what do you mean when you say it's not the PHP runtime?
 
6:43 PM
I guess you may have missed the beginning of the conversation @Sherif
 
@bwoebi Yes.
@Caleb Believe me I've been having this conversation since 2006. I haven't missed a thing.
 
I am talking about running a CLI HTTP Server that runs a thread per request and storing some objects in shared memory
 
@Caleb Yea, that already sounds like the millionth time I've had this conversation with someone.
 
@MadaraUchiha perfect moment. =D
 
6:45 PM
There's a reason why mod_php and php-fpm fork and don't thread
What happens when one request crashes PHP?
 
@Caleb yeah, right, because adding threads will make it all better
 
Do you take down 1K requests? Or do you just take down 1?
 
@Caleb That approach is tried. It doesn't scale past a few dozen concurrent connections when you have complex logic
 
@MadaraUchiha s/dozen/hundred/ … but still
 
Oh it has nothing to do with sacle
You could get it to scale just fine
 
6:46 PM
@Sherif As you could a LOLCODE web server
 
The problem is... it's a horrible architecture choice for the web
 
The question is how much sweat, blood and tears you'd have to shed.
 
This is why PHP already thought of this back in 1995
 
@Sherif Because one process per request is sooo much better, right?
 
But hey, if you want to abandon 20 years of wisdom and start making up your own shit... by all means... good luck!
 
6:47 PM
It's all crap, lol
 
@MadaraUchiha It is when that one process is responsible for a single request.
 
@Sherif s/thought/pretended didn't exist/ - which turned out to be the right choice, for the wrong reasons.
 
You just work with what works best for you
 
It's for a small microservice that provides realtime information on 1 part of an application for around 5 concurrent users
 
@Danack What reasoning are you referring to there?
 
6:48 PM
I like the approach of an event loop with worker threads when needed a lot better than PHP's process based approach, or Java's thread based approach
But that's me.
Amazing applications were built on PHP, Node, Java, C#, C++, etc.
 
I'm not running a whole app in one multithreaded PHP CLI process...
 
@Caleb if it's just for 5 users, can't you then just simply refetch?
 
The language/framework really doesn't matter as long as you can express yourself well in it
 
5 users per job
 
It's a matter of personal choice and goals.
 
6:49 PM
could be a bunch of jobs going on at once
 
"This is why PHP already thought of this back" - they didn't think about it, it was just too difficult to implement so they didn't.
 
@MadaraUchiha That's still a process-based approach and not at all unlike PHP's mod_php or php-fpm approach. They're both based on a prefork MPM.
 
@Sherif ... One process, one event loop
That's not a "process-based approach"
 
@MadaraUchiha Oh, you want to do concurrency inside the event loop? heh
good luck with that
 
2 mins ago, by Madara Uchiha
I like the approach of an event loop with worker threads when needed a lot better than PHP's process based approach, or Java's thread based approach
 
6:50 PM
@MadaraUchiha Same issue. If you thread, what happens if one of your threads crashes?
You lose every single request...
There's no advantage to threading over forking in this context.
 
@Sherif "Worker threads" being short-living threads that perform a task to not block the CPU, and die when their jobs are done
Thread synchronization might be fast, but it's a major PITA that really no one wants to deal with.
 
@MadaraUchiha spawning a thread isn't very cheap
 
@MadaraUchiha I understand what a thread is. What happens when one of your threads crash?
 
@Sherif The request fails, and the next one will spawn a new oen
 
You understand that a segmentation fault inside a thread crashes the entire process, right?
 
6:52 PM
one (or request a new one from the threadpool)
 
No, you take down the entire process you lose all of your threads.
You seem confused.
 
@Sherif how often do you plan to segfault?
 
@Sherif you can catch it though in a signal handler… there are solutions... [not that you should do that ^^]
 
that's not like a common thing
 
@Caleb At scale? PHP segfaults more than you think.
 
6:52 PM
A segafault?
You're expecting a segfault during a normal operation?
 
use a supervisor, duh!
 
In NodeJS?
 
@Sherif PHP only segfaults in edge cases and with opcache.
 
@bwoebi I'm aware of the solutions. I just don't find them interesting enough to bother solving when there are better solutuions.
 
If you've had a segfault during normal operation, you either found serious bugs with PHP, or you have serious issues with your code.
 
6:53 PM
@bwoebi I have a 27TB error log that says different :)
You assume the only thing we're talking about is the engine
There's a lot of wonky extension code out there
 
@Sherif I don't write comments on my code in Swedish just in case a Swedish dev comes along to read my code
I don't plan for segfaults to happen during normal execution, and if they do, there's a serious bug either in my code or in the platform
Both are fixable.
 
@MadaraUchiha You're missing the point. The point is not how often it segfaults. It's how many concurrent requests you lose when it does.
 
@Sherif yes, talking about most common exts and core ^^ everything else… beware ^^
 
Even if it takes 1 in 1M requests when a segfault occurs.... if you're serving 1K concurrent requests when it does... you lose 1K requests.
 
@Sherif How many concurrent requests will you lose if your server undergoes a critical failure and crashes?
That can happen too...
 
6:55 PM
Whereas with an MPM prefork you only lose 1
@MadaraUchiha Sure it can, but that's why we scale wide
Probabalistically you want to minimize damage as much as possible
 
Unless Apache segfaults lol
 
I've yet to see Node segfault on me, and I've been hammering with it for quite a while, on nontrivial apps
I acknowledge that it might happen, but the cost of handling that case or taking all these things into account is too great for me to care about
 
@MadaraUchiha as said… it's not the core, but the extensions…
 
Just because you haven't seen something happen doesn't mean it doesn't happen.
 
@bwoebi I don't use libraries/extensions I don't trust
 
6:57 PM
Anyway, you're still completely ignoring the point.
 
I've read the source of most of the libraries I use regularly
 
Why maximize your damage when you have an option that allows you to minimize it?
 
hi
 
Architectural design details are about preventing failures... not hoping they won't happen.
 
@Sherif It really depends on what's the cost of the alternative.
 
6:58 PM
@MadaraUchiha I wish everyone would do that =D
 
Why echo gmdate("j\/m\/o", strtotime('1998-08-23')); is printing 22/08/1998 instead of 23/08/1998?
 
@bwoebi I was really surprise the first time I found out that most devs don't
 
@MadaraUchiha Well, in regards to catastrophic failure I just laid out the cost for you.
 
"You mean, you're just letting people who you've never met run arbitrary code on your app without looking? wat"
@Sherif It's not just the cost
It's how likely are we to get into that scenario
Extensions to the platform written in native C code are both a blessing and a curse, and should be used with EXTREME caution
 
Well thanks for the tips everyone. Maybe I'll try the multi-threaded server thing. @bwoebi aerys looks nice, excited to give it a shot
 
7:01 PM
is this php chat?
 
The real problem with Node's approach is that by default, an uncaught application error would terminate the server process
 
Why echo gmdate("j\/m\/o", strtotime('1998-08-23')); is printing 22/08/1998 instead of 23/08/1998?
 
@Azevedo yes, sure ^^
@Azevedo seriously, I don't know.
 
oh
thanks
 
@MadaraUchiha Well according my last architecture review meeting the average segfault occurs about 1:10M requests with upgrade events usually account for about 50% of those segfaults. Since those don't typically happen during peak hours that would account for roughly about ~50K/req sec, which would mean a single segfault on a single worker (were it threaded) would take down roughly ~2K requests per segfault.
That means you'd probably piss off about 1M people
 
7:02 PM
So, for example, if your server takes 5 seconds to start, and someone found a URL that causes an uncaught error, they can DoS you with 12 requests/min which is trivial
 
When you could have just limited to may be a few hundred.
But hey, what the fuck do I know. I just work here.
 
@Sherif If segfaults are that significant in your particular usecase, it makes sense to plan for them
For me, it's for more likely that a 3rd party library I installed threw an error that wasn't caught, and as a result, took down my entire server
So it makes sense for me to plan against those kinds of problems
 
@MadaraUchiha that's what catch-all handlers are for…
 
Node doesn't have extensions, and so doesn't segfault very often.
@bwoebi Yup, but there are a few tricky cases
For example, how do you treat an unhandled rejection from a Promise?
 
@MadaraUchiha When does it not make sense to plan for failure?
 
7:08 PM
Do you error? warn? ignore? If you error out, when?
@Sherif When chances of failure are slim, and changing a well tested architecture is costly.
My points of failure are different to yours, both because of different platform and different scale
 
@MadaraUchiha How do you know the chances of failure are slim if you haven't planned for them?
How do you know what the cost of failure is unless you plan for it?
See any flaws in your logic thus far?
 
@Sherif Because I've been at this for several years and never had one.
 
@MadaraUchiha Ahh, so you associate "it's never happened to me before" with "I planned for failure well"
Gothcya
 
You can also prepare for a zombie apocalypse, the risk of which is catastrophic and is probably well worth preparing for. However, even without preparing or planning I can tell you the chances are slim
 
@MadaraUchiha That's not true. All you can tell me with any degree of certainty is that it hasn't happened yet.
 
7:11 PM
@Azevedo it's adjusted for the local/gmt timezone difference (with your strtotime giving a local time of midnight)
 
You don't know what the chances are unless you investigate the facts and use models to understand the data.
 
@Sherif Welp, better start prepping for a zombie apocalypse then...
It's a question of where I'm putting my time
 
@MadaraUchiha If my business depended on it, I certainly would.
 
I'm putting my time on something that, based on my personal past experience, has better chances of getting better results
I've not done any formal research, nor have I checked the facts on every single edge case on the platform I'm on
 
My job depends on me understanding the risks of failure. So I spend a great deal of my time uncovering those risks and proving them with data.
 
7:13 PM
And so far, for the past few years, it paid off well.
 
I tried making shit up, but they didn't believe me :/
 
@Sherif Right, and mine doesn't :)
Not to the level yours requires, anyway.
 
@MadaraUchiha I didn't suggest any such thing. But based on this conversation you seem to be ignoring data and presenting your predilections matter-of-factly. That's all I can say based on current observation.
Science is about being able to reproduce results and create proofs. Not merely guess at the problem.
 
@Sherif When I work, I normally try to account for changes in requirements and scale.
I program extremely defensively and provide an abstraction over any part of the application I deem worthy of a representation
This allows me to react, rather than plan
I could sit and plan for weeks ahead of time, and have a 50% chance of nailing an architecture to last a decade
Or I could plan for a few hours, start with a MVP, have a solid infrastructure in place, have unit tests with high coverage rate, and continue from there
I found that the latter is far far more productive in application development, especially when you can just stop in the middle to reevaluate your choices, and since you have unit tests for all, you can shift things around with high confidence
Planning is important, but reactability is more.
 
@MadaraUchiha Yea, architecture is not for everyone. Reactive is the defacto modus operandi of any engineer trying to build a complex system.
 
7:19 PM
@Sherif As a self-learner and an indie dev for a while (I'm now employed fulltime) I learned to be my own QA, IT, designer, frontend, backend, and tester, all in one. So I know a bit of everything
But being extremely good at all of those is hard
That's why companies have teams of specialized people :)
 
@MadaraUchiha "a fox knows many things, but a hedgehog one important thing""
 
@Sherif "Jack of all trades, but master of none. Still much better than master of one" is one I really liked
 
@MadaraUchiha I guess that's where you and I part ways. I rather enjoy solving interesting problems. I don't really wish to bother with boring problems. Being surface-deep opens you up to little more than boring problems.
 
@Sherif Oh, I specialized
I specialize in UI and UX
I just know about the "environment" as well, rather than trying to ignore the existence of the server (like a lot of people I know)
 
@MadaraUchiha UI/UX is a more of a product/design area. It really has no firm roots in the field of software engineering.
So if that's where your specialty lies I can fully understand the confusion.
 
7:27 PM
@Sherif Yeah, that's what most server people say
 
LOL, what're server people?
 
It actually has quite a bit to do with software engineering (mainly when talking about performance)
@Sherif People who like to pretend like JavaScript isn't a real language, and that the client isn't as or more important than the server.
 
@MadaraUchiha I mean to say that it has no applications in the field of software engineering.
@MadaraUchiha Hey, I don't make fun of JavaScript. It does a good enough job of that all on its own, but actually I've never meet anyone doing UI/UX that does javascript beyond "Hello World" stuff, to be perfectly honest with you.
Most of them can't even get that far.
They're usually considered sub-front-end in all of the organizations I've worked for.
 
@Sherif Well, I do functional programming, Rx programming, promises, coroutines, the whole deal
But to me, JavaScript is a tool to get there, it's not the point.
The user doesn't care about your beautiful architecture and magnificent abstractions
 
So do you ship front-end code to production?
 
7:33 PM
They care about getting shit done, and ASAP
@Sherif Yeah
And backend code too
UI/UX is my passion, and where most of my work is at.
 
Cool, then you're probably ahead of the curve from all the UI/UX guys/gals I've met.
 
But I do everything.
 
And 6 months later the customer complains about the time it takes to make modifications, because they didn't care about any fancy framework :)
 
@MadaraUchiha They sure will when your system is stable and doesn't go down every 5 minutes (even if they don't know it)
 
@Sherif Programming is a team effort
 
7:34 PM
end-users don't thank you for architecture. They just don't complain when things aren't breaking because of your architecture
 
The backend is the payload and the front-end is the engine
 
Once you can wrap your head around that you just got architecture.
 
You need both for a successful rocket.
Otherwise, it would just blow up in your face.
 
No doubt.
 
@MadaraUchiha ignore. If you don't watch for the Promise, you probably don't care about the result or exception.
An unwatched Promise is basically "please try".
 
7:37 PM
@bwoebi What if I did have a .then() handler (or however you call it)
But it never fired because the promise rejected?
(But no .catch() handler)
It's a design decision, there's no right answer (and I don't expect one)
 
@bwoebi Is that like "I promise I'll buy you a ring some day..."?
/me hides
 
@Sherif hehe =)
 
I always attach rejection handlers on my promises, but I can't guarantee that internal promises used by libraries do the same
 
@MadaraUchiha same. that's basically like an unwatched then() result.
 
The default in Node is to throw.
 
7:39 PM
I disagree with that design decision. But well… that's subjective.
 
You have a global function that you can set to handle uncaught rejections (similar to PHP's set_error_handler() for Promises
 
You mean set_exception_hanlder()?
 
After all, you might not have a watcher for the Promise yet when the Deferred is being failed
 
@Sherif SSDD, PHP's error handling is meh :D
@bwoebi Node is a bit funky
Say you have a function call to fs.readFile("file.txt", (err, data) => { ... })
readFile will read the file "behind the scenes" and call the callback with the data or error when needed
That would be nice... only sometimes, fs.readFile might throw synchronously.
 
and how is that related to Promises now?
 
7:42 PM
Node made quite a few assumptions and opinionated design decisions
 
Did it? That's just the V8 engine what you're describing there.
 
I think JS's approach to Promises, while opinionated on itself, has proved to be quite useful/successful.
@Sherif The fs.readFile thing?
No, that's a strictly Node API.
 
@MadaraUchiha you can build great things on top of crap… that's not really an argument
 
No, that part would be the API.
I'm referring to the behavior.
 
@bwoebi Well, we are in the PHP room...
 
7:44 PM
touché
 
@bwoebi You mean like the Windows kernel?
 
@MadaraUchiha I do great things which PHP by using its great features =D
@Sherif oh god. Please don't come with this :x
 
Because someone realized that at some point crap(q) > greatstuff(p)
 
@bwoebi You mean the even distribution of the function name lengths, or the goto someone did as an exercise and got it merged into PHP? :P
 
You can't hand me a can of worms and tell me not to open it!
OK, I go back to work now...
carry on
 
7:46 PM
@MadaraUchiha Javascript has similar stories, I just don't know about them.
 
@bwoebi Of course it does
 
Most languages have…
 
Every language has them, that's exactly my point that "stuff is opinionated and as long as we're comfortable with what we do and manage to express ourselves in that language it doesn't matter what we pick"
 
yep :-)
 
It's like arguing which is better, English or Hebrew. The answer is: "Whichever feels better to use at any given situation"
 
7:48 PM
@MadaraUchiha English definitely, because I don't understand the latter =P
 
You're both wrong. French is better!
I win!
/me disappears again
 
PHP English is horrible, you should totally drop that and learn Common Lisp Hebrew. Everyone should read/write Common Lisp Hebrew!
 
@Sherif French? I'm very sorry, mais c'est une langue terrible…
 
evenin'
 
@bwoebi meh, take that back. just because it is difficult, doesn't make it a terrible language :p
 
7:51 PM
@FélixGagnon-Grenier It's not difficult, but I don't like the semantics… even Latin is better.
 
it's a lovely language to listen to, though I don't understand it... I also rather like tagalog for that (reminds me of bubbling water)
 
French is my third language…
@PaulCrovella Agree, the sound is nice
 
I'll admit it is less punchy than english is
 
how bout chinese :D
 
7:53 PM
@FélixGagnon-Grenier I admit that terrible is a hyperbole, but I'd classify French as a more … inferior language.
 
I'd say less widely spreadable
much more exceptions (for the best of my knowledge, I ain't no english language specialist)
 
@NikiC why ugh?
 
@bwoebi I just don't understand what goes on in the heads of people like that
 
@FélixGagnon-Grenier passé simple irrégulier … [bah messed up adjective order ^^]
 
How can you even come up with defined(array('ANIMALS' => 'dog'))?
Oh the list RFC is at exactly 22:11
 
7:57 PM
@NikiC maybe it just was a crappy example to illustrate?
 
I wonder if I should ruin it :P
 
@NikiC yes. And don't vote no :-P
 
@bwoebi I'll vote yes to counteract your vote
j/k I haven't actually read the rfc
 
@Sherif ... I have voted yes…
 
oh wait I read that wrong
(:more coffee time)
 

« first day (1946 days earlier)      last day (2999 days later) »