Coarse-grained vs fine-grained

TerminologyGranularity

Terminology Problem Overview


What is the difference between coarse-grained and fine-grained?

I have searched these terms on Google, but I couldn't find what they mean.

Terminology Solutions


Solution 1 - Terminology

From Wikipedia (granularity):

> Granularity is the extent to which a > system is broken down into small > parts, either the system itself or its > description or observation. It is the > extent to which a larger entity is > subdivided. For example, a yard broken > into inches has finer granularity than > a yard broken into feet. > > Coarse-grained systems consist of > fewer, larger components than > fine-grained systems; a coarse-grained > description of a system regards large > subcomponents while a fine-grained > description regards smaller components > of which the larger ones are composed.

Solution 2 - Terminology

In simple terms

  • Coarse-grained - larger components than fine-grained, large subcomponents. Simply wraps one or more fine-grained services together into a more coarse­-grained operation.
  • Fine-grained - smaller components of which the larger ones are composed, lower­level service

It is better to have more coarse-grained service operations, which are composed by fine-grained operations

enter image description here

Solution 3 - Terminology

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.

Solution 4 - Terminology

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

Solution 5 - Terminology

In the context of services:

http://en.wikipedia.org/wiki/Service_Granularity_Principle

> By definition a coarse-grained service operation has broader scope > than a fine-grained service, although the terms are relative. The > former typically requires increased design complexity but can reduce > the number of calls required to complete a task.

A fine grained service interface is about the same like chatty interface.

Solution 6 - Terminology

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.

Solution 7 - Terminology

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 100100 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 10050 + 50 only.

Solution 8 - Terminology

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.

Solution 9 - Terminology

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.

Solution 10 - Terminology

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.

Solution 11 - Terminology

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLoveTWView Question on Stackoverflow
Solution 1 - TerminologyMichael PetrottaView Answer on Stackoverflow
Solution 2 - TerminologyTechieView Answer on Stackoverflow
Solution 3 - TerminologyHumaun Rashid NayanView Answer on Stackoverflow
Solution 4 - TerminologySumeer SinhaView Answer on Stackoverflow
Solution 5 - Terminologyuser3285954View Answer on Stackoverflow
Solution 6 - TerminologyManish PansariView Answer on Stackoverflow
Solution 7 - TerminologySunView Answer on Stackoverflow
Solution 8 - TerminologyAbhishek SinghView Answer on Stackoverflow
Solution 9 - TerminologyPinaki MukherjeeView Answer on Stackoverflow
Solution 10 - TerminologySagar SharmaView Answer on Stackoverflow
Solution 11 - TerminologyAbir RezaView Answer on Stackoverflow