没有合适的资源?快使用搜索试试~ 我知道了~
首页Spring+Cassandra+Redis等构建实时应用的集群与扩展策略
Spring+Cassandra+Redis等构建实时应用的集群与扩展策略
需积分: 9 3 下载量 199 浏览量
更新于2024-07-18
收藏 3.09MB PDF 举报
"《Pro Java Clustering and Scalability》是一本融合编程实践与基础设施讨论的编程书籍,作者Jorge Acetozi以丰富的开发经验和实战案例引导读者。本书特别关注实时应用的构建,使用了Spring框架、WebSocket、Cassandra、Redis、RabbitMQ以及MySQL等技术栈。作者不仅展示了如何通过Spring搭建一个实时应用,还深入探讨了如何实现水平扩展,特别是在多节点WebSocket架构的设计上,这是本书的独特之处。 书中采用了FLAT DESIGN和COLORFUL BACKGROUND的设计风格,使得阅读体验既专业又生动。内容涵盖了从基础到高级的主题,如系统设计原则和Java编程的最佳实践,旨在为读者提供一种全新的学习体验。作者在编写过程中,将大量实际代码与基础设施管理的理论知识相结合,确保读者既能掌握开发技能,又能理解如何优化系统的可扩展性和性能。 全书适用于那些希望通过实践了解如何在大规模并发和分布式环境中应用这些技术的开发者,无论是初学者还是经验丰富的工程师,都能从中找到有价值的信息。此外,书中的版权信息表明,所有内容受到版权保护,禁止未经许可的复制、翻译或任何形式的再利用,体现了对知识产权的尊重。 通过阅读《Pro Java Clustering and Scalability》,读者不仅能提升自己的编程能力,还能学习到关于分布式系统、数据库管理和消息队列的实用知识,这对于理解和构建高可用、可扩展的现代应用程序至关重要。这是一本兼具实用性和教育价值的书籍,是IT专业人士不可或缺的参考资料。"
资源详情
资源推荐
■ INTRODUCTION
xix
protected void configureStompEndpoints(StompEndpoint
Registry registry) {
registry.addEndpoint("/ws").withSockJS();
}
public void configureMessageBroker(MessageBroker
Registry registry) {
registry.enableStompBrokerRelay("/queue/", "/topic/")
.setUserDestinationBroadcast("/topic/unresolved.user.dest")
.setUserRegistryBroadcast("/topic/registry.broadcast")
.setRelayHost(relayHost)
.setRelayPort(relayPort);
registry.setApplicationDestinationPrefixes("/chatroom");
}
}
For this code snippet, I would explain everything but the @Configuration
and @Value annotations, which are basic parts of Spring.
This doesn’t mean you can’t read this book and consult other resources
when you feel it’s needed (by the way, I provide a lot of resources in this book).
PART 1
Usage
Before looking at the architecture and the code of the chat application,
let’s get the application up and running and configure the development
environment on your machine so that you can get the most from this book.
3
© Jorge Acetozi 2017
J. Acetozi, Pro Java Clustering and Scalability, DOI 10.1007/978-1-4842-2985-9_1
CHAPTER 1
Docker
The chat application dependencies are pretty straightforward to set up when
using Docker. In this chapter, you’ll learn what Docker is and also how to use the
main Docker commands to manage services running on containers.
This chapter is intended to illustrate the basic usage of Docker for running
containers. It will not cover important topics such as how to build Docker images,
which is beyond the scope of this book, because you are using Docker only to set
up the dependencies for the chat application.
1.1 Introduction to Docker
In short, Docker allows you to easily run services on a machine. Docker
guarantees that these services will always be in the same state across executions,
regardless of the underlying operating system or system libraries.
This means if you distribute version 1.0.0 of the chat application developed
in this book as a Docker image, then it’s guaranteed that the application will
behave the same for everyone who runs this image using Docker, regardless of
whether they are running it on Windows, macOS, or Linux.
Try to remember how many times you’ve heard the sentence “I don’t know
what’s happening; it works on my machine.” When dealing with enterprise
applications, it’s a common practice to promote an artifact (a release candidate
version) through many environments (such as testing and staging) before
eventually deploying it to production. In an ideal world, these environments
should be mirrors of the production environment, but in practice, this is not what
typically happens. Usually, these environments run on different machines, on
different operating systems, and with different library versions, so the problem of
“It works on staging; I don’t know why it’s not working on production” gets even
worse. That’s where Docker turns out to be an amazing tool; it guarantees that
regardless of those environment differences, the artifact will behave the same.
CHAPTER 1 ■ DOCKER
4
This is perhaps the most important characteristic that Docker offers.
But there are many more.
• It’s easy to run services as Docker containers. Thus, it also
helps a lot in the development phase because you don’t
have to waste time installing and configuring tools on your
operating system.
• Docker is a highly collaborative tool. You can reuse Docker
images that people build and share publicly.
• It encourages the infrastructure as code model because
a Docker image is entirely described on a file called a
Dockerfile that can (and should) be versioned.
• Docker has a great community, and it’s expanding quickly.
Docker installation may vary on different operating systems, so I suggest you
follow the official docs to install Docker
1
on your machine. Make sure you are
installing Docker version 1.13.0 or newer.
1.2 Docker Hub
As I mentioned, using Docker is a pretty elegant way to run services on a
machine without having, in fact, to install them on the operating system. It
accomplishes this by instantiating containers, which are Linux virtualizations
running on the same kernel as the host operating system but isolated from it. For
example, if you create a file inside a container, this file cannot be accessed from
the host operating system (unless you specify that explicitly).
Each container should run a specific service, which is instantiated from
a Docker image previously built, stored, and shared on a Docker registry. The
official public Docker registry is Docker Hub,
2
where you can find many prebuilt
images for almost everything you need.
For instance, say you want to spin up an Elasticsearch cluster on your local
machine. You can go to Docker Hub, type Elasticsearch into the search field,
and choose the image that best fits your needs. Some tools have official images
(maintained by the Docker team), and some do not. Anyone can sign up at
Docker Hub, create their own images, and publish them publicly. This makes
Docker a highly collaborative tool.
1
https://docs.docker.com/engine/installation/
2
https://hub.docker.com
CHAPTER 1 ■ DOCKER
5
It’s also possible to publish private Docker images, but you must pay for this
feature if you want to publish more than one private image.
1.3 Image vs. Container
Basically, Docker images are binary files that contain everything needed to run
a specific service. When you instantiate a service from a Docker image, you say
that you create a Docker container. As an analogy, if a Docker image is a Java
class, then a Docker container is an object. You create a container by executing
the docker run command.
1.4 Image Tags
The docker run command requires that you provide the image name. Here’s an
example:
$ docker run jenkins
Here, jenkins is the image name. If Docker cannot find the jenkins image
locally, then it will try to pull it from Docker Hub. A Docker image can have a tag
associated with it, which usually indicates the service version. To run a specific
tag, just add : to the image name and provide the tag.
$ docker run jenkins:2.32.3
If the tag is not provided, Docker will try to pull the latest tag. A common
misunderstanding is that the
latest tag means the “newest image version
available,” but this may not be true. The
latest tag is just a tag that’s used when
you don’t provide any other while you are building a Docker image; it doesn’t mean
that it’s the newest version.
When dealing with an official Docker image (like the jenkins image earlier),
you do not provide a username. But if you are using a nonofficial image, you
need to provide the owner’s username and the image name as follows:
$ docker run username/image_name:tag
剩余141页未读,继续阅读
cbweixin
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 多模态联合稀疏表示在视频目标跟踪中的应用
- Kubernetes资源管控与Gardener开源软件实践解析
- MPI集群监控与负载平衡策略
- 自动化PHP安全漏洞检测:静态代码分析与数据流方法
- 青苔数据CEO程永:技术生态与阿里云开放创新
- 制造业转型: HyperX引领企业上云策略
- 赵维五分享:航空工业电子采购上云实战与运维策略
- 单片机控制的LED点阵显示屏设计及其实现
- 驻云科技李俊涛:AI驱动的云上服务新趋势与挑战
- 6LoWPAN物联网边界路由器:设计与实现
- 猩便利工程师仲小玉:Terraform云资源管理最佳实践与团队协作
- 类差分度改进的互信息特征选择提升文本分类性能
- VERITAS与阿里云合作的混合云转型与数据保护方案
- 云制造中的生产线仿真模型设计与虚拟化研究
- 汪洋在PostgresChina2018分享:高可用 PostgreSQL 工具与架构设计
- 2018 PostgresChina大会:阿里云时空引擎Ganos在PostgreSQL中的创新应用与多模型存储
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功