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

override the redundancy based on the resizer #292

Merged
merged 1 commit into from
Dec 7, 2020
Merged

Conversation

poonai
Copy link
Member

@poonai poonai commented Dec 5, 2020

  let mut children = children
        .with_redundancy(3) // Start with 3 actors
        .with_heartbeat_tick(Duration::from_secs(5)); // Do heartbeat each 5 seconds

    #[cfg(feature = "scaling")]
    {
        children = children.with_resizer(
            OptimalSizeExploringResizer::default()
                .with_lower_bound(1) // A minimal acceptable size of group
                .with_upper_bound(UpperBound::Limit(2)) 
                .with_upscale_strategy(UpscaleStrategy::MailboxSizeThreshold(3)) // Scale up when a half of actors have more than 3 messages
                .with_upscale_rate(0.1) // Increase the size of group on 10%, if necessary to scale up
                .with_downscale_rate(0.2), // Decrease the size of group on 20%, if too many free actors
        );
    }

The above code will panic at https://github.com/bastion-rs/bastion/blob/master/src/bastion/src/resizer.rs#L254 because redundancy is 3 is higher than the upper bound.

This PR overwrites the minimum number actor will be spawned based on the recent argument pass. It can be via a resizer or redundancy.

Still, we need to catch the places like lower bound can't be higher than the upper bound. Wondering how we can put such sanity checks ergonomically.

Signed-off-by: பாலாஜி <rbalajis25@gmail.com>
@poonai poonai requested review from Relrin and vertexclique December 5, 2020 11:01
@Relrin
Copy link
Member

Relrin commented Dec 5, 2020

The fix for scaling could rely on the special call that will be called right after the value being set in the with_lower_bound/with_upper_bound method. It could be called something like align_bounds

But in general, this code looks ok to me.

Copy link
Member

@vertexclique vertexclique left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. thanks.

@vertexclique vertexclique merged commit bd6c164 into master Dec 7, 2020
@vertexclique vertexclique deleted the balaji/resizer branch December 7, 2020 11:29
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

Successfully merging this pull request may close these issues.

3 participants