You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Vibhath Ileperuma <vi...@gmail.com> on 2021/04/20 11:59:26 UTC

Clarification of controller services

Hi all,

In NIFI user guide, it is mentioned that controller services are shared
services. What does it exactly mean?
We can use a single service object with multiple processors. For example,
we can use the same CSVRecordSetWriter with a PartionRecord processor and a
UpdateRecord processor. Is it like accessing the same java object from
multiple threads? Is there any negative or positive impact on performance
when using multiple objects of the same service instead of a single service
object?

Thanks & Regards

*Vibhath Ileperuma*

Graduate | ENTC

University of Moratuwa

E vibhatharunapriya@gmail.com

M 0772715343

Re: Clarification of controller services

Posted by Vibhath Ileperuma <vi...@gmail.com>.
Thank you Mark..

On Tue, 20 Apr 2021, 7:00 pm Mark Payne, <ma...@hotmail.com> wrote:

> Vibhath,
>
> Yes, the object itself is shared across those different processors, and
> the object is accessed concurrently by multiple threads.
>
> Is there any impact on performance? This depends entirely on the
> implementation of the Controller Service. If I have a Controller Service
> with a method named “doSomething” and it’s implemented like this:
>
> public String doSomething() {
>     return “done”;
> }
>
> Then there’s no impact on performance when using multiple threads. But if
> it’s implemented like this:
>
> public String toSomething() {
>     lock.lock();
>     try {
>        return doSomethingExpensive();
>     } finally {
>         lock.unlock();
>     }
> }
>
> Then you may have a huge performance penalty because only a single thread
> at a time will perform the action “doSomethingExpensive” and any other
> threads will block, executing only one at a time.
>
> Thanks
> -Mark
>
>
>
> On Apr 20, 2021, at 7:59 AM, Vibhath Ileperuma <
> vibhatharunapriya@gmail.com> wrote:
>
> Hi all,
>
> In NIFI user guide, it is mentioned that controller services are shared
> services. What does it exactly mean?
> We can use a single service object with multiple processors. For example,
> we can use the same CSVRecordSetWriter with a PartionRecord processor and a
> UpdateRecord processor. Is it like accessing the same java object from
> multiple threads? Is there any negative or positive impact on performance
> when using multiple objects of the same service instead of a single service
> object?
>
> Thanks & Regards
>
> *Vibhath Ileperuma*
>
> Graduate | ENTC
>
> University of Moratuwa
>
> E vibhatharunapriya@gmail.com
>
> M 0772715343
>
>
>

Re: Clarification of controller services

Posted by Mark Payne <ma...@hotmail.com>.
Vibhath,

Yes, the object itself is shared across those different processors, and the object is accessed concurrently by multiple threads.

Is there any impact on performance? This depends entirely on the implementation of the Controller Service. If I have a Controller Service with a method named “doSomething” and it’s implemented like this:

public String doSomething() {
    return “done”;
}

Then there’s no impact on performance when using multiple threads. But if it’s implemented like this:

public String toSomething() {
    lock.lock();
    try {
       return doSomethingExpensive();
    } finally {
        lock.unlock();
    }
}

Then you may have a huge performance penalty because only a single thread at a time will perform the action “doSomethingExpensive” and any other threads will block, executing only one at a time.

Thanks
-Mark



On Apr 20, 2021, at 7:59 AM, Vibhath Ileperuma <vi...@gmail.com>> wrote:

Hi all,

In NIFI user guide, it is mentioned that controller services are shared services. What does it exactly mean?
We can use a single service object with multiple processors. For example, we can use the same CSVRecordSetWriter with a PartionRecord processor and a UpdateRecord processor. Is it like accessing the same java object from multiple threads? Is there any negative or positive impact on performance when using multiple objects of the same service instead of a single service object?

Thanks & Regards

Vibhath Ileperuma

Graduate | ENTC

University of Moratuwa

E vibhatharunapriya@gmail.com<ma...@gmail.com>

M 0772715343