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/

编辑推荐精选

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

Refly.AI

Refly.AI

最适合小白的AI自动化工作流平台

无需编码,轻松生成可复用、可变现的AI自动化工作流

酷表ChatExcel

酷表ChatExcel

大模型驱动的Excel数据处理工具

基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。

AI工具酷表ChatExcelAI智能客服AI营销产品使用教程
TRAE编程

TRAE编程

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

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

AI工具TraeAI IDE协作生产力转型热门
AIWritePaper论文写作

AIWritePaper论文写作

AI论文写作指导平台

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

AI辅助写作AI工具AI论文工具论文写作智能生成大纲数据安全AI助手热门
博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

AI办公办公工具AI工具博思AIPPTAI生成PPT智能排版海量精品模板AI创作热门
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

iTerms

iTerms

企业专属的AI法律顾问

iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。

SimilarWeb流量提升

SimilarWeb流量提升

稳定高效的流量提升解决方案,助力品牌曝光

稳定高效的流量提升解决方案,助力品牌曝光

Sora2视频免费生成

Sora2视频免费生成

最新版Sora2模型免费使用,一键生成无水印视频

最新版Sora2模型免费使用,一键生成无水印视频

下拉加载更多