Kraken is the first and only multi-processed, multi-threaded, fault-tolerant framework for PHP. It has been written to provide easy and reliable API for creating distributed applications using PHP. Kraken aims to solve typical problems of writing such applications and to provide developers with powerful yet elegant tools for dealing with them.
Start writing applications that were previously marked as impossible or hard to implement in PHP right now. Servers, service-oriented architecture, agent-based models, games, complex daemons, socket programs, schedulers and much, much more - nothing is impossible with Kraken!
Divide your application into several containers and run them on multiple threads, processors or hosts.
Write systems that self-heal using remote and local supervision hierarchies.
To emit and listen on events the Event-Emitters are used. Each component is built around them allowing architecture to be as loose-coupled and extensible as possible. The framework allows to implement additional modules using either synchronous or asynchronous emitter classes, interfaces and traits to fully cater to various needs.
Managing distributed and dynamic architecture using only event-pattern can become problematic and fault-prone as the project expands. To keep things reliable and rapid the framework ships with its own implementation of Promises/A+ specification. All higher level interfaces shipped with framework use promise-pattern to keep coding easy.
In addition to many modules delivered with framework, one of the most important are the asynchronous TCP and UDP sockets. Developers can use them as pure IPC communication endpoints, build on top of them more advanced controllers for specialized protocols or send and receive data from external services with an easy event-based interface.
Processing big amount of data is not be possible to be done with reasonable usage of resources without using streams. To deal with this, Kraken provides various asynchronous and synchronous stream controllers. Writers, Readers, Seekers, Duplex streams, pipes and more complex interfaces are provided.
The most popular Web protocols, HTTP and Websockets, are supported through a standalone server. Framework is able to handle requests and produce asynchronous responses for them and its sub-protocols. In addition firewalls, routers, session-saving mechanisms and protocol encoders are featured.
Writing multi-processed and multi-threaded applications is supported and simplified with a simple and consistent interface. Developer do not longer need to think about forking and creating php threads manually or how to store and clean them. Everything is done automatically using several fallback layers and keeps to work independently.
Distributed processing between active processes and threads is designed to work as actor-based distribution models do. Processes and threads extends common container class and are treated as separate actors. Each actor can work independently or in cluster. Thanks to shared interface operating on containers does not require from architect to remember which of them are processes and threads.
To make utterly perfect MT programs developers don't need mutexes, locks, or any other form of inter-thread communication except messages sent across endpoints. With this idea in mind, the whole concept of exchanging information between contaiers is purely message-driven. Framework, by default, ships with several different IPC that programmer can use individually or all-together.
To ensure system reliability, each one of containers is equipped with configurable supervisor systems. These allow developers to define and inject strategies defining how to react to thrown errors and exceptions. Access to both local and remote supervisors makes possible to deal with them locally or delegate decision-handling to one of the parents.
All communication between containers is enclosed to special controllers called Channels. They provide single abstract interface to exchange data, regardless of IPC model chosen to do the job. Each one consists of configurable routers, message & protocol encoders and IPC abstraction layer. Define the way of passing messages once, make it adaptive and see how easy sending and receiving messages gets.
Aside from code manipulation the framework support parsing messages received through command line. Use console clients to execute predefined tasks, change state and structure of working architecture without need to restart everything. Write your own commands to extend its effect to your business logic. Use console servers to be able to divide your architecture to multiple hosts easily and manage all of them from single place.
Code has been written in PHP 5.5+ and PHP 7.0+ in mind. It is fully compatible and tested on both of them.
By default framework ships with React adapters to make its components usable. Any of React core or based-on modules is able to work perfectly in Kraken environment.
All required to work mechanics including managing processes and threads is written in a platform-independent way to allow framework to be run on both Unix and Windows operating systems.
Able to emit millions of events per second
Able to handle tens of thousands of messages and promises per second
Several times faster than traditional PHP approach
Scalable for multiple processes and threads
Able to extend over 100% performance under pressure for limited amount of time
Faster than standard libraries running on Node.js
Start writing asynchronous, multi-processed, multi-threaded application in PHP right now and be amazed how easy the whole process gets thanks to Kraken Interface. Try it now for free.
Still have some questions? Visit one of our pages of interest listed below or ask the community.