Colossus is a lightweight framework for building high-performance applications in Scala that require non-blocking network I/O. In particular Colossus is focused on low-latency stateless microservices where often the service is little more than an abstraction over a database and/or cache. For this use case, Colossus aims to maximize performance while keeping the interface clean and concise.
Applications are built around a set of single-threaded event loops which handle the low-level network interactions, but these event loops are themselves actors which can send and receive messages. The result is an environment where you are able to write low-level event-handling code directly in the event loop, but move other parts into actors with ease.
Built directly on NIO, Colossus is a modern take on event-based programming that fully leverages the functional and object-oriented features of Scala. Write powerful applications with minimal boilerplate.
Written entirely as Akka actors, Colossus makes it easy to connect your low-level event-handling code with external actors. Colossus also comes with a fully actor-based API if you wish to keep all your code inside actors.
Colossus comes with a metrics aggregation and reporting system that makes it easy to track events in real-time. Common metrics like request rates and latency are built into services out of the box, and it's easy to add your own. A SQL-like DSL allows you to filter and aggregate over these metrics, while a reporting module lets you package and export metrics to an external database like OpenTSDB.
While Colossus has primarily been built with microservices in mind, at the heart is a simple wrapper on NIO that is fully accessible for you to write your own custom servers and clients. Furthermore, Colossus Tasks let you write arbitrary code inside event loops when you need to do I/O outside the context of a server.
libraryDependencies += "com.tumblr" %% "colossus" % "0.5.0"import colossus._
import service._
import protocols.http._
import UrlParsing._
import HttpMethod._
object Main extends App {
implicit val io_system = IOSystem()
Service.become[Http]("http-echo", 9000){
case request @ Get on Root => request.ok("Hello world!")
case request @ Get on Root / "echo" / str => request.ok(str)
}
}Ready for more? Take a look at:
Colossus was built to address many of the challenges we've faced at Tumblr when writing Scala services. It has greatly simplified the development process, allowing engineers to rapidly build services that are production-ready with minimal effort. Colossus is currently used in several production systems throughout Tumblr's infrastructure.
We need your help!. Colossus is still in the early stages of development and while we've met many of the goals we set out to achieve, there's still much to be done. Features need to be implemented, bugs needs to be fixed, optimizations need to be optimized. If you find a bug or have a cool idea, let us know and get involved!