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

Adding support for multiple subgroups #128

Merged
merged 7 commits into from Jan 12, 2024
Merged

Adding support for multiple subgroups #128

merged 7 commits into from Jan 12, 2024

Conversation

Maelkum
Copy link
Collaborator

@Maelkum Maelkum commented Jan 7, 2024

This PR adds support for multiple work subgroups.

Subgroups are formed by introducing multiple pubsub topics to which work (roll calls) are published to. Changes are backwards compatible - if no explicit configuration is done, everything should work like before, and all nodes use the default topic as before (blockless/b7s/general).

Operators can instruct their work nodes to make themselves available to specific topics of work by using CLI parameters, e.g. node --topic blockless/b7s/topic1 --topic blockless/b7s/topic3. Note that worker can include a list of topics. The default topic is always included as it's used to transmit some general data like health pings.

To direct work to a subgroup, HTTP requests to the head node execution endpoint (/api/v1/functions/execute) should include the subgroup field, e.g.

{
    "subgroup": "blockless/b7s/topic1",
    "function_id": "{{hello-world-cid}}",
    "method": "{{hello-world-wasm}}",
    "config": {
        "number_of_nodes": 2,
        "result_aggregation": {
            "enable": false,
            "type": "none",
            "parameters": [
                {
                    "name": "type",
                    "value": ""
                }
            ]
        }
    }
}

If the subgroup is not specified, it's published to the general topic, which all worker nodes belong to.

Worker nodes have to have their topics specified on boot, and they will subscribe to all of them. However, head nodes do not. If a head node sees a subgroup it has not seen before, it will try to join that topic and publish to it, even if it's new to it (fanout messages). This makes the head node more flexible and doesn't require it to know a lot in advance.

Function install messages can also be directed to a specific subgroup.

Since we now have multiple subscriptions for ingress messages, main node run loop has been somewhat tweaked (and can be cleaner, but will be in a later PR).

@Maelkum Maelkum self-assigned this Jan 7, 2024
@Maelkum Maelkum requested a review from dmikey January 7, 2024 18:49
Copy link
Contributor

@dmikey dmikey left a comment

Choose a reason for hiding this comment

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

I think this makes total sense.

There is only 1 execution per topic?

@Maelkum
Copy link
Collaborator Author

Maelkum commented Jan 9, 2024

I think this makes total sense.

There is only 1 execution per topic?

Oh, I think you're right - I've lost sight of limiting parallelism. But I accidentally went the other way. We limit how many messages we queue (from all topics) but when draining the queue we execute all of them asynchronously. Before (as it should be) we had a limit on how many concurrent executions we had. I'll amend this tomorrow when I'm back.

Good catch! 🕵️

@Maelkum Maelkum merged commit 7ed1220 into main Jan 12, 2024
2 checks passed
@Maelkum Maelkum deleted the multiple-topics branch January 12, 2024 13:54
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.

None yet

2 participants