scalecube-services

scalecube-services

响应式微服务框架助力高性能系统构建

ScaleCube是一款专注于高吞吐量和低延迟的微服务框架,适合构建可扩展的响应式系统。它提供卓越的API网关集成、服务发现和负载均衡功能,并采用SWIM协议实现高效集群管理。ScaleCube的模块化架构支持多种可插拔通信模块,便于灵活部署。通过优化实时流处理和增强容错能力,ScaleCube为分布式微服务环境提供稳定高效的性能支持。

微服务ScaleCube分布式系统响应式编程服务发现Github开源项目

scalecube-services

Maven Central SourceSpy Dashboard

MICROSERVICES 2.0

ScaleCube is a microservices library designed for high throughput and lower latency, catering to scalable and reactive system needs. It excels in API gateway integration, service discovery, and load balancing, employing the SWIM protocol for efficient cluster management. Its modular architecture supports various pluggable communication modules, enabling seamless and flexible deployments. With a focus on real-time stream processing and fault tolerance, ScaleCube ensures optimal performance and reliability for distributed microservices environments.

Reactive microservices communicate via streams, utilising asynchronous data flows to exchange information between services. This approach enhances system responsiveness and scalability by allowing services to process and react to data as it arrives, without blocking operations.

In practice, this involves using technologies and protocols that support reactive streams, such as Reactor. These tools enable the development of highly responsive, resilient systems capable of handling dynamic workloads efficiently.

<table text-align="top"> <tr> <td> A fully mesh, brokerless architecture is particularly beneficial for high-performing, reliable, and scalable applications. <br> It ensures continuous availability and responsiveness, making it ideal for real-time data processing, large-scale distributed systems, and environments where minimizing latency matters. <br><br> ScaleCube’s fully mesh architecture delivers a robust, efficient, and scalable solution for modern microservices applications, enhancing system performance and reliability without the need for complex middleware setups. </td> <td> <img src="https://user-images.githubusercontent.com/1706296/43058327-b4a0147e-8e4f-11e8-9999-68c4ec99632e.gif"> </td> </tr> </table> ScaleCube Services Features:
  • Provision and interconnect microservices peers in a cluster
  • Fully Distributed with No single-point-of-failure or single-point-of-bottleneck
  • Fast - Low latency and high throughput
  • Scaleable over- cores, jvms, clusters, regions.
  • Built-in Service Discovery and service routing
  • Zero configuration, automatic peer-to-peer service discovery using SWIM cluster membership protocol
  • Simple non-blocking, asynchronous programming model
  • Reactive Streams support.
    • Fire And Forget - Send and not wait for a reply
    • Request Response - Send single request and expect single reply
    • Request Stream - Send single request and expect stream of responses.
    • Request bidirectional - send stream of requests and expect stream of responses.
  • Built-in failure detection, fault tolerance, and elasticity
  • Routing and balancing strategies for both stateless and stateful services
  • Embeddable into existing applications
  • Natural Circuit-Breaker via scalecube-cluster discovery and failure detector.
  • Support Service instance tagging.
  • Support Service discovery partitioning using hierarchy of namespaces in a multi-cluster deployments.
  • Modular, flexible deployment models and topology
  • pluggable api-gateway providers (http / websocket / rsocket)
  • pluggable service transports (tcp / aeron / rsocket)
  • pluggable encoders (json, SBE, Google protocol buffers)
  • pluggable service security authentication and authorization providers.

User Guide:

Basic Usage:

The example provisions 2 cluster nodes and making a remote interaction.

  1. seed is a member node and provision no services of its own.
  2. then microservices variable is a member that joins seed member and provision GreetingService instance.
  3. finally from seed node - create a proxy by the GreetingService api and send a greeting request.
// service definition @Service("io.scalecube.Greetings") public interface GreetingsService { @ServiceMethod("sayHello") Mono<Greeting> sayHello(String name); } } // service implementation public class GreetingServiceImpl implements GreetingsService { @Override public Mono<Greeting> sayHello(String name) { return Mono.just(new Greeting("Nice to meet you " + name + " and welcome to ScaleCube")); } } //1. ScaleCube Node node with no members (container 1) Microservices seed = Microservices.builder() .discovery("seed", ScalecubeServiceDiscovery::new) .transport(RSocketServiceTransport::new) .startAwait(); // get the address of the seed member - will be used to join any other members to the cluster. final Address seedAddress = seed.discovery("seed").address(); //2. Construct a ScaleCube node which joins the cluster hosting the Greeting Service (container 2) Microservices serviceNode = Microservices.builder() .discovery("seed", ep -> new ScalecubeServiceDiscovery(ep) .membership(cfg -> cfg.seedMembers(seedAddress))) .transport(RSocketServiceTransport::new) .services(new GreetingServiceImpl()) .startAwait(); //3. Create service proxy (can be created from any node or container in the cluster) // and Execute the service and subscribe to incoming service events seed.call().api(GreetingsService.class) .sayHello("joe").subscribe(consumer -> { System.out.println(consumer.message()); }); // await all instances to shutdown. Mono.whenDelayError(seed.shutdown(), serviceNode.shutdown()).block();

Basic Service Example:

  • RequestOne: Send single request and expect single reply
  • RequestStream: Send single request and expect stream of responses.
  • RequestBidirectional: send stream of requests and expect stream of responses.

A service is nothing but an interface declaring what methods we wish to provision at our cluster.

@Service public interface ExampleService { @ServiceMethod Mono<String> sayHello(String request); @ServiceMethod Flux<MyResponse> helloStream(); @ServiceMethod Flux<MyResponse> helloBidirectional(Flux<MyRequest> requests); }

API-Gateway:

Available api-gateways are rsocket, http and websocket

Basic API-Gateway example:

Microservices.builder() .discovery(options -> options.seeds(seed.discoveryAddress())) .services(...) // OPTIONAL: services (if any) as part of this node. // configure list of gateways plugins exposing the apis .gateway(options -> new WebsocketGateway(options.id("ws").port(8080))) .gateway(options -> new HttpGateway(options.id("http").port(7070))) .gateway(options -> new RSocketGateway(options.id("rsws").port(9090))) .startAwait(); // HINT: you can try connect using the api sandbox to these ports to try the api. // https://scalecube.github.io/api-sandbox/app/index.html

Maven

With scalecube-services you may plug-and-play alternative providers for Transport,Codecs and discovery. Scalecube is using ServiceLoader to load providers from class path,

You can think about scalecube as slf4j for microservices - Currently supported SPIs:

Transport providers:

  • scalecube-services-transport-rsocket: using rsocket to communicate with remote services.

Message codec providers:

Service discovery providers:

Binaries and dependency information for Maven can be found at http://search.maven.org.

https://mvnrepository.com/artifact/io.scalecube

To add a dependency on ScaleCube Services using Maven, use the following:

Maven Central

<properties> <scalecube.version>2.x.x</scalecube.version> </properties> <!-- ------------------------------------------- scalecube core and api: ------------------------------------------- --> <!-- scalecube apis --> <dependency> <groupId>io.scalecube</groupId> <artifactId>scalecube-services-api</artifactId> <version>${scalecube.version}</version> </dependency> <!-- scalecube services module --> <dependency> <groupId>io.scalecube</groupId> <artifactId>scalecube-services</artifactId> <version>${scalecube.version}</version> </dependency> <!-- Plugins / SPIs: bellow a list of providers you may choose from. to constract your own configuration: you are welcome to build/contribute your own plugins please consider the existing ones as example. --> <!-- scalecube transport providers: --> <dependency> <groupId>io.scalecube</groupId> <artifactId>scalecube-services-transport-rsocket</artifactId> <version>${scalecube.version}</version> </dependency>

Sponsored by:

We Hire at exberry.io

https://exberry.io/career/

website

https://scalecube.github.io/

编辑推荐精选

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

热门AI工具生产力协作转型TraeAI IDE
商汤小浣熊

商汤小浣熊

最强AI数据分析助手

小浣熊家族Raccoon,您的AI智能助手,致力于通过先进的人工智能技术,为用户提供高效、便捷的智能服务。无论是日常咨询还是专业问题解答,小浣熊都能以快速、准确的响应满足您的需求,让您的生活更加智能便捷。

imini AI

imini AI

像人一样思考的AI智能体

imini 是一款超级AI智能体,能根据人类指令,自主思考、自主完成、并且交付结果的AI智能体。

Keevx

Keevx

AI数字人视频创作平台

Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。

即梦AI

即梦AI

一站式AI创作平台

提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作

扣子-AI办公

扣子-AI办公

AI办公助手,复杂任务高效处理

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI助手AI工具AI写作工具AI辅助写作蛙蛙写作学术助手办公助手营销助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

聊天机器人AI助手热门AI工具AI对话
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

热门AI工具AI办公办公工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图
下拉加载更多