Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Virtual Thread Dispatcher for Pekko Projections #233

Open
JacobF7 opened this issue Nov 15, 2024 · 5 comments
Open

Support Virtual Thread Dispatcher for Pekko Projections #233

JacobF7 opened this issue Nov 15, 2024 · 5 comments

Comments

@JacobF7
Copy link

JacobF7 commented Nov 15, 2024

Currently, Pekko Projections only support the blocking-jdbc-dispatcher (see https://pekko.apache.org/docs/pekko-projection/current/jdbc.html). Are there any plans to start supporting a new dispatcher that uses Virtual Threads, similar to what has been achieved in the standard actor dispatcher ?

@pjfanning
Copy link
Contributor

I don't understand why we would want to support a non-blocking dispatcher here.
If you want, you can just change your own config to replace the thread-pool-executor with a virtual-thread-executor. I wouldn't recommend it but it in theory, it should work. Get back if there is some check that limits the type of executor that you can plugin.

@JacobF7
Copy link
Author

JacobF7 commented Nov 15, 2024

Don't you think that since the Event Handlers need to persist into the database (blocking operation), we may benefit from using Virtual Threads since blocking on I/O doesn't block the OS Thread?

If we wanted to try using Virtual Thread Threads, do you suggest specifying our own dispatcher definition with the executor set to "virtual-thread-executor" ?

Edit: I've tried adding the above, but it doesn't seem to be working. Here goes a snippet of my conf:


   use-dispatcher = "pekko.projection.jdbc.virtual-thread-jdbc-dispatcher"

   virtual-thread-jdbc-dispatcher {
     type = Dispatcher
     executor = "virtual-thread-executor"
     virtual-thread-executor {
     }
     throughput = 100
   }

@pjfanning
Copy link
Contributor

If we wanted to try using Virtual Thread Threads, do you suggest specifying our own dispatcher definition with the executor set to "virtual-thread-executor" ?

I answered this in #233

If you want, you can just change your own config to replace the thread-pool-executor with a virtual-thread-executor.

@JacobF7
Copy link
Author

JacobF7 commented Nov 15, 2024

I've updated one of my comments above. But, in any case, here a snippet of my conf for projections. I've tried investigating what type of thread is executing inside the projection handler and it seems as though it's not a Virtual Thread.

  pekko.projection {
    jdbc.dialect = postgres-dialect

    use-dispatcher = "pekko.projection.jdbc.virtual-thread-jdbc-dispatcher"

    virtual-thread-jdbc-dispatcher {
      type = Dispatcher
      executor = "virtual-thread-executor"
      virtual-thread-executor {
      }
      throughput = 100
    }
  }

@pjfanning pjfanning transferred this issue from apache/pekko Nov 15, 2024
@pjfanning
Copy link
Contributor

I had a quick look at the code and I can't see anything that would prevent this from working. There are no logs or reproducible test cases to back the assertion that it doesn't work. I may have time later in the week to try to test this myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants