Introducing UCall
UCall is an innovative project designed to simplify and accelerate network communication. It is a JSON Remote Procedure Calls (RPC) library that claims to be up to 100 times faster than FastAPI, making it an attractive option for developers looking for performance and ease of use.
Simplifying Setup
One of the key advantages of UCall is its simplicity. Just like with FastAPI, you can get started with UCall with a single installation command:
- FastAPI setup requires:
pip install fastapi uvicorn
- UCall setup requires:
pip install ucall
The simplicity extends to the code as well. While FastAPI needs several dependencies and a bit more code to define a server and handlers, UCall simplifies this with a minimalistic approach:
-
FastAPI example:
from fastapi import FastAPI import uvicorn server = FastAPI() @server.get('/sum') def sum(a: int, b: int): return a + b uvicorn.run(...)
-
UCall example:
from ucall.posix import Server server = Server() @server def sum(a: int, b: int): return a + b server.run()
Performance Boost
UCall boasts impressive performance metrics, especially when compared to traditional alternatives like FastAPI and gRPC. The library leverages cutting-edge technologies, such as io_uring
, and SIMD-accelerated parsers, to achieve high-speed data handling and processing.
For example, using UCall with io_uring
on a new C server configuration results in a latency of only 22 microseconds and a throughput of 231,000 requests per second. This is significantly faster than what FastAPI can manage.
Advanced Functionality
Not only does UCall provide a speed advancement, but it also extends beyond the traditional capabilities of FastAPI. It supports types such as numpy.ndarray
and PIL.Image
, which are particularly useful when dealing with applications related to AI and data processing. Here's a glimpse into how UCall handles complex data tasks:
from ucall.rich_posix import Server
import uform
server = Server()
model = uform.get_model('unum-cloud/uform-vl-multilingual')
@server
def vectorize(description: str, photo: PIL.Image.Image) -> numpy.ndarray:
image = model.preprocess_image(photo)
tokens = model.preprocess_text(description)
joint_embedding = model.encode_multimodal(image=image, text=tokens)
return joint_embedding.cpu().detach().numpy()
Command Line Interface
UCall incorporates a powerful command-line interface, similar to cURL
, allowing users to interact with servers, send requests, and manage files seamlessly. This feature enables developers to write scripts or manually test out server functionality in an efficient and straightforward manner.
Flexible Usage
Beyond the Python ecosystem, UCall provides compatibility with CMake projects. It enables developers to integrate UCall into various programming environments, making it a versatile tool across different platforms.
The Road Ahead
UCall's roadmap includes enhancing its functionality with HTTPS support, batch processing endpoints for machine learning tasks, and integration with other Unum-Cloud projects like UKV. This roadmap shows a strong commitment to improved secure transactions and advanced data processing capabilities.
Why JSON-RPC?
UCall utilizes JSON-RPC for its transport independence, allowing flexibility in the choice of protocols like TCP or UDP. It simplifies argument passing as well, making it more straightforward compared to REST API's multiple ways of handling requests.
UCall is an ambitious project that promises a blend of speed, simplicity, and advanced features for developers looking to leverage network communications efficiently. Whether it’s for a basic setup or a high-demand application, UCall stands out as a competitive choice in the world of remote procedure calls.