This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 months ago.
The community reviewed whether to reopen this question 7 months ago and left it closed:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(11)
来自维基百科(粒度):
From Wikipedia (granularity):
简单来说
最好有更多的粗粒度服务操作,这些操作由细粒度操作组成
In simple terms
It is better to have more coarse-grained service operations, which are composed by fine-grained operations
粗粒度:一些对象保存了大量相关数据,这就是服务具有更广泛功能范围的原因。示例:单个“帐户”对象保存客户姓名、地址、帐户余额、开户日期、最后更改日期等。
因此:增加了设计复杂性,减少了各种操作的单元数量
细粒度:更多的对象,每个对象持有更少的数据,这就是服务的功能范围更窄的原因。示例:Account 对象保存余额,Customer 对象保存姓名和地址,AccountOpenings 对象保存开仓日期等。
因此:降低了设计复杂性,增加了用于各种服务操作的单元数量。
这些是这些对象之间定义的关系。
Coarse-grained: A few ojects hold a lot of related data that's why services have broader scope in functionality. Example: A single "Account" object holds the customer name, address, account balance, opening date, last change date, etc.
Thus: Increased design complexity, smaller number of cells to various operations
Fine-grained: More objects each holding less data that's why services have more narrow scope in functionality. Example: An Account object holds balance, a Customer object holds name and address, a AccountOpenings object holds opening date, etc.
Thus: Decreased design complexity , higher number of cells to various service operations.
These are relationships defined between these objects.
另一种理解方法是考虑进程和线程之间的通信。进程借助套接字、信号处理程序、共享内存、信号量和文件等粗粒度通信机制进行通信。另一方面,线程可以访问属于进程的共享内存空间,这允许它们应用更细粒度的通信机制。
来源:Java 并发实践
One more way to understand would be to think in terms of communication between processes and threads. Processes communicate with the help of coarse grained communication mechanisms like sockets, signal handlers, shared memory, semaphores and files. Threads, on the other hand, have access to shared memory space that belongs to a process, which allows them to apply finer grain communication mechanisms.
Source: Java concurrency in practice
在服务上下文中:
http://en.wikipedia.org/wiki/Service_Granularity_Principle
细粒度的服务接口与聊天接口大致相同。
In the context of services:
http://en.wikipedia.org/wiki/Service_Granularity_Principle
A fine grained service interface is about the same like chatty interface.
就文本文件之类的数据集而言,粗粒度意味着我们可以转换整个数据集,但不能转换数据集上的单个元素,而细粒度意味着我们可以转换数据集上的单个元素。
In term of dataset like a text file ,Coarse-grained meaning we can transform the whole dataset but not an individual element on the dataset While fine-grained means we can transform individual element on the dataset.
粗粒度和细粒度都是考虑优化一些服务。但区别在于级别。我喜欢用例子来解释,你会很容易理解。
细粒度:比如我有findbyId、findbyCategry、findbyName……等100个服务。为什么我们不能提供 find(id、category、name...等等),而不是那么多服务。这样我们就可以减少服务。这只是一个例子,但目标是如何优化服务数量。
粗粒度:例如,我有100个客户端,每个客户端都有自己的一组100个服务。所以我必须提供100*100的全服务。这是非常困难的。相反,我所做的是,我将适用于大多数客户的所有通用服务识别为一个服务集并单独保留。例如,在 100 个服务中,有 50 个服务是常见的。所以我只需要管理100*50 + 50。
Coarse-grained and Fine-grained both think about optimizing a number of servicess. But the difference is in the level. I like to explain with an example, you will understand easily.
Fine-grained: For example, I have 100 services like findbyId, findbyCategry, findbyName...... so on. Instead of that many services why we can not provide find(id, category, name....so on). So this way we can reduce the services. This is just an example, but the goal is how to optimize the number of services.
Coarse-grained: For example, I have 100 clients, each client have their own set of 100 services. So I have to provide 100*100 total services. It is very much difficult. Instead of that what I do is, I identify all common services which apply to most of the clients as one service set and remaining separately. For example in 100 services 50 services are common. So I have to manage 100*50 + 50 only.
粗粒度并不总是意味着更大的组件,如果你按照“粗”这个词的字面意思来看,它意味着严酷或不合适。例如,在软件项目管理中,如果将一个小系统分解为几个组件,这些组件大小相同,但复杂性和功能各不相同,这可能会导致粗粒度。相反,对于细粒度的细分,您可以根据每个组件提供的功能的内聚性来划分组件。
Coarse-grained granularity does not always mean bigger components, if you go by literally meaning of the word coarse, it means harsh, or not appropriate. e.g. In software projects management, if you breakdown a small system into few components, which are equal in size, but varies in complexities and features, this could lead to a coarse-grained granularity. In reverse, for a fine-grained breakdown, you would divide the components based on their cohesiveness of the functionalities each component is providing.
粗粒度和细粒度。这两种模式都定义了如何共享核心
多个 Spark 任务之间。顾名思义,细粒度模式是
负责在更细粒度的级别上共享核心。 细粒度模式已被 Spark 弃用,并将很快被删除。
coarse grained and fine grained. Both of these modes define how the cores are shared
between multiple Spark tasks. As the name suggests, fine-grained mode is
responsible for sharing the cores at a more granular level. Fine-grained mode has been deprecated by Spark and will soon be removed.
与细粒度服务相比,科西嘉粒度服务提供更广泛的功能。根据业务领域,可以创建单个服务来服务单个业务单元,或者如果子单元很大程度上彼此独立,则可以创建专门的多个细粒度服务。
粗粒度服务可能会变得更加困难,由于其规模而不太适应变化,而细粒度服务可能会引入管理多个服务的额外复杂性。
Corse-grained services provides broader functionalities as compared to fine-grained service. Depending on the business domain, a single service can be created to serve a single business unit or specialised multiple fine-grained services can be created if subunits are largely independent of each other.
Coarse grained service may get more difficult may be less adaptable to change due to its size while fine-grained service may introduce additional complexity of managing multiple services.
粒度在存储空间非常重要的大规模数据时具有重要的应用。
根据牛津词典,粒度的含义是 -
“一组数据的详细程度或程度。”
根据剑桥词典 -
“信息中包含很多小细节,使你可以非常清楚地了解正在发生的事情”
所以从这个词的具体含义来看,它是一种连续过程的数据划分。
更细的粒度由小区间划分组成,从而可以实现详细的表示。
另一方面,较粗的粒度就是较大的帧间隔,这样可以节省存储空间。
两种粒度的使用是特定于应用程序的。
例如,如果我们有一个应用程序,其中最近的时间信息比旧的信息更重要。对于最近数据的详细表示,可以通过更细的粒度找到,而对于较旧的数据表示,我们可以使用较粗的粒度。
Granularity has an important application while storing large scale data where space is very important.
The meaning of granularity according to Oxford dictionary is -
"The scale or level of detail in a set of data."
According to Cambridge dictionary -
"A lot of small details included in information, making it possible for you to understand very clearly what is happening"
So from the word specific meaning, it is some kind of partition of data for a continuous process.
Finer granularity consists of small interval partition, so that detailed representation can be achieved.
On the other hand, coarser granularity is larger frame interval, so that it can save storage.
Uses of two types of granularity is application specific.
For example- If we have an application, where recent time information is more important than the older information. For detailed representation of recent data can be found by finer granularity, while for older data representation we can use coarser granularity.