Tag Archives: featured

Request Loop

It’s been a while since I last posted…

There is always a reason for that. My reason was a sum of many different variables. Just as the great mentor said, luck is the sum of many coincidences, that’s what happened in my case as well.

Where do I begin?

Jobwise: Capital controls, working day and night, a lot to do and no time to do it…

Blogwise: I had a very strange setup with my blog (and a very very outdated one I might add). Since I am using Heroku, they decided to change their stack and migrate from Cedar 10 to Cedar 14 . Ok I said what the hell lets do it.

Alas, I had a serious problem with libssl0.98 which was built inside my php module and was not supported in Cedar 14. (whoever wants to do the upgrade have a look here first).

Long story short I fixed it, and I also found that many posts I did with various hacks for the pg4wp plugin were incorporated into a single release from kevinoid : here

I will contribute also into some changes that have to be taken into account since the module is quite old and I have previously stated that it’s not at all well written.

That’s not the main point of this post though.

I wanted to share an experience I keep coming across lately.

Now according to popular trends we are experiencing (and will experience in the future) a huge bloom of the microserviced architecture. This guy here explains how and why they decided to go for the microserviced architecture.

I agree. There are many benefits when having a monolithic single (and obsolete at times) repo for web applications. It is a nice solution when your company is scaling, and you have to maintain a lot of different parts. Especially if you have different teams and each team wants to “do their own thing” about a solution.

However it’s not the solution to Everything!

I will elaborate more:

I recently had to debug an http step based procedure (client requests this page, books this ticket, goes there, etc.) that was using 3 different instances of different technologies over http. The one was python and wsgi, the second was php with apache and the third one was ruby with unicorn.

Try to debug this. I dare you. Seriously. I had in my local setup all 3 different instances running with 3 different IDE’s and all running their debugger. Ok, ok you say that Docker will simplify the installation. I agree it does, but it does not help the debugging at all.

The most important thing though isn’t the debug/testing of many different apps over http.

It’s the HTTP by itself.

And believe me, I have seen a lot of “Senior” Devs falling into the same trap of API’zation and doing over and over the same architectural error.

The Request Loop

You won't guess how many time's I've seen this happening...
You won’t guess how many time’s I’ve seen this happening…

Consider the following diagram:

This is the actual loop - when one request is still open, another comes along, and things get messy...
This is the actual loop – when one request is still open, another comes along, and things get messy…

The Browser  sends a request to the Frontend app. Now the Frontend App could forward it (or change it a bit) to the Backend App.

In our setup the backend app was a PHP app.

Now since PHP by default does not support threading (not pthreads), each HTTP request is a different PHP thread, served via apache.

This is very complicating, since you keep a connection (process) open and you open another one which could (at some point maybe) rely on data from the first one. You cannot access that data in between processes.

Not to mention that, you can not either debug this thing, since you insert a break point in the first request procedure, and the second request (which happens a few ms after) is being served without the debugging stopping at that point.

My point is that when you decide to go Microservice’d

Try to avoid request looping, when you need to do something that is synchronous. Or, use something different. Do threading. Use a message queue, or something else.

You will be surprised how much time you will spend trying to debug and understand what is wrong in this set-up.

I will close with the following meme:

Some people, when confronted with a problem, think, “I know, I’ll use threads,” and then two they hav erpoblesms.

Anger! Unlimited, Unmetered ANGERRRR!

Developer Anger!

Developers often face situations where logic bends. Now this happens quite a few times. Suppose we have an equation with factors that the outcome of this equation is the “bending logic”.

The first factor, and larger at times is the client input. “Yes, we know we asked for that, but now things have changed, so we have to change it” , “What? I did not ask for a red line drawn with a blue pen!” and so on. More on that at The Expert.

The second factor is the programming language we are using. And that is the point were we stand for now.  Third and fourth factors is experience and capability but those are irrelevant on each person so, we wont be discussing them now.

ANGER. WRITING CODE THAT SEEMS TO WORK.

Quite recently I stumbled upon this interesting site :

http://www.commitlogsfromlastnight.com/

Turns out that this guy: @abestanway is parsing repos from github and records each curse in the commit log message. A commit log message is a message we developers use when we are completing a project/code snippet/change/bug in the code of a system we are using.

This guy, took it to another step also. He gathered data and created a presentation, showing the languages with the most curses. He even created graphs of the most cursed and least cursed language:

Curses / Language
Curses / Language

As you can see, Javascript is the first. Undoubtedly this language is the most widely used, so it makes sense for it to have the most curses (and yeah many other stuff you already know like changeling scopes and other Javascript shitty stuff).

He also created graphs with the most used curses:

See that Fuck prevails all!!
See that Fuck prevails all!!

Next, he compared the Most Cursed languages with the most used languages in Github. You can have a look at all the above from the relevant video :

Therefore :

ANGERRRRRRRRRRRR
UNLIMITED ANGERRRRR!

To conclude he points out that the more the curses, the better the code…

Coding is a Way of Life

When it comes to coding

I often find myself looking back at those years while in the high school and later in the university. It turns out that both those institutions that in terms made me who I am, did not provide sufficient knowledge on how to write and run computer software.

Playing a little bit the part of devil’s advocate, I think I always had it in me. Were those small Visual Basic scripts I often tended to write while in high school. Were afterwards in the university, the endless hours trying to “optimize” the given university projects. That all combined provided me the technical “thirst” for further development.

That development in terms of skills and more coding, was mostly provided by myself. I was the one searching to find more stuff to do. Not the university. Not the high school either. I had literally no one to guide me into this procedure. For all I cared, especially in the university where you could choose the courses, I could have chosen a much more easy path, without the computer programming skills. That’s what it was everyone was suggesting anyway. Since this path was the easiest in terms of engineering.

Being at 2014, this should ultimately change. We live in a world where computers are honestly playing a huge part. I do not think that there should be a single child in the fore-coming years that does not know even the basic principles of computer coding and algorithms.

Although, I personally did not like Steve Jobs (for various reasons), I do believe in his following words:

everybody

Watch this video. You will appreciate the things you do. And reflect for the future of our kids. Coding will literally give you super human powers in the future…