The facts: We are talking about a small company (5 persons) with many clients that making real money (we don't) . We provide our own software that has unique features against the e-commerce completion.
The problem: the first glimpse of the problem arose around 2012 and made clear around 2014 with web sockets. Some clients didn't want a simple chat with their client but instead a full live eShop where they could negotiate the prices of a product or even start a discussion with a visitor. The solution would be implementing web sockets in to our framework and that worked , but using incredible resources without any sideway compensation benefits. What that could be ?: 1) we use app scope caching (for object or list of objects) and thought that is done in the memory of the server, each request you have to deserialize / serialize (if there are changes) objects (that is CPU expensive and time consuming , I calculated that it cost almost 2 milliseconds in each response). More over if I have something running along with the app why not having a DB pool where the most common prepared statement persists?
The first solution: Was a new PHP framework that was basically a C++ extension , everything worked fine (almost (if someone interesting I could share more)) (it went in production only in one project). Application scope caching was working with lockers when those objects updated, and we could have a first r&d glimpse in db pooling in PHP. More over it would eliminate DNS lookup since the SPA app would hook to the WebSocket if available or to AJAX if not. (when I am talking about SPA here you would see the same content if you visit a URL for the first time as if you visit it through an inner link).
And then PHP 7.0.2 came: The incontinences of PHP are monumental, but the all thing shattered in the ground. In fact we weren't trying to produce a framework we were trying to produce an application server that would hold that framework. The application server part could be done with more resources and in a specific PHP version, but we don't have the resources nor do we want to bind ourselves to a specific PHP version.
The /lets move back/ moment: There is a language that you can use an application server ,you can share application scope caching objects without deserializing / serializing and also has many add ons for web sockets and more its easy and I have know know it since teenager (no it wasn't my first language) , that language is Java and an application server along with it like Tomcat for example.
The decision is difficult to make , switching to Java , would require rewriting all of our apps , but the two main goals will be achieved (app scope caching , db pool). On the other hand there is a limit to understanding how a JVM is working internally and to write good code for that , using system extensions (example imageMagick).
One plus for Java would be that after that we could share our java code without classes and one serious downside would be that we coudn't write more C++ extensions to make our life easier + faster + more efficient. But to maintain a PHP application server is far more difficult than I first thought.
I would highly appreciate any point of views on that , since I am in a crossroad.