Skip to content

support multiple instance with the same writekey #273

@RanjitCS

Description

@RanjitCS

Is your feature request related to a problem? Please describe.
We have a scenario where multiple JVMs (essentially replicas of each other) are configured to use the same analytics-kotlin.properties file and share the same events directory. Under high load, we’ve observed that the file-index property fluctuates unexpectedly (e.g., jumping from 1–100, then back to 50, etc.).

Upon investigation, we noticed that the StorageImpl class uses semaphores for synchronization; however, this mechanism does not provide protection against concurrent file access by multiple processes. Some events also seem to be dropped/skipped over due to this.We would like to ensure that the read/write operations are always in sync

Describe the solution you'd like
Would it be possible to change to a file locking mechanism instead of semaphore? Or some other solution to protect multiple processes accessing same file/folder?

Describe alternatives you've considered
We are considering a few alternatives.

  1. Separate files/folders per JVM: The simplest approach is to assign unique files or directories for each JVM instance. However, this introduces new challenges: if a JVM crashes or is stopped unexpectedly, the location of its files/folders can be lost, requiring a separate helper process to recover or transfer batch files to the new instance’s directory. The new instance that comes up would not be able to use the same files/folders as before as we would need to have a unique identifier for each JVM and there is a chance that we could lose events.

  2. Custom StorageImpl with FileLocks: As a last resort, we’re contemplating building our own version of StorageImpl that implements robust file locking internally.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions