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

examples: add example for ORCA load reporting #6114

Merged
merged 3 commits into from
Mar 14, 2023
Merged

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Mar 10, 2023

cc @temawi

RELEASE NOTES:

  • examples: add example for ORCA load reporting

@dfawley dfawley added the Type: Documentation Documentation or examples label Mar 10, 2023
@dfawley dfawley added this to the 1.54 Release milestone Mar 10, 2023
@dfawley dfawley requested a review from easwars March 10, 2023 21:22
Comment on lines 22 to 27
pieces are optional and work independently. For per-RPC metrics to be
reported, two things are important: 1. using `orca.CallMetricsServerOption()`
when creating the server and 2. setting metrics in the method handlers by using
`orca.CallMetricRecorderFromContext()`. For out-of-band metrics, one simply
needs to create and register the reporter by using `orca.Register()` and set
metrics on the returned `orca.Service` using its methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you do bulleted lists for this to make it easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rewrote as part of above to not have #s anymore.


## Explanation

The server is set up to report query cost metrics in its RPC handler. It also
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel that it might be easier to read if you split this section into per-rpc metrics and oob metrics. And then talk about the APIs, what the server does and what the client does per section.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reworked a bit.

examples/features/orca/client/main.go Show resolved Hide resolved
pb.RegisterEchoServer(s, &server{})

// Register the orca service for out-of-band metric reporting, and set the
// maximum reporting frequency to once every 3 seconds. Note that, by
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only place where maximum is used. Should this also be minimum?

Copy link
Member Author

Choose a reason for hiding this comment

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

Higher frequency = faster = shorter interval. Confusing. I'll just remove any mention of "frequency".

sc.Connect()

// Register a simple ORCA OOB listener on the SubConn. We request a 1
// second report interval, but in this example the minimum interval is 3
Copy link
Contributor

Choose a reason for hiding this comment

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

A small clarification to say that the 3s interval is set by the server would be useful I feel.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

examples/features/orca/client/main.go Show resolved Hide resolved
Comment on lines +47 to +50
conn, err := grpc.Dial(*addr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"orca_example":{}}]}`),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Even though this is just an example, it would be nice if we don't split up lines this way. We should either have everything on a single line, or define a dial options slice to initialize the dial options.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why? This seems like purely personal preference. We do this in other places in our examples, too, like:

roundrobinConn, err := grpc.Dial(
fmt.Sprintf("%s:///%s", exampleScheme, exampleServiceName),
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"round_robin":{}}]}`), // This sets the initial balancing policy.
grpc.WithTransportCredentials(insecure.NewCredentials()),
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed offline & agreed to leave this.

@easwars easwars assigned dfawley and unassigned easwars Mar 10, 2023
Copy link
Member Author

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

pb.RegisterEchoServer(s, &server{})

// Register the orca service for out-of-band metric reporting, and set the
// maximum reporting frequency to once every 3 seconds. Note that, by
Copy link
Member Author

Choose a reason for hiding this comment

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

Higher frequency = faster = shorter interval. Confusing. I'll just remove any mention of "frequency".


## Explanation

The server is set up to report query cost metrics in its RPC handler. It also
Copy link
Member Author

Choose a reason for hiding this comment

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

Reworked a bit.

Comment on lines 22 to 27
pieces are optional and work independently. For per-RPC metrics to be
reported, two things are important: 1. using `orca.CallMetricsServerOption()`
when creating the server and 2. setting metrics in the method handlers by using
`orca.CallMetricRecorderFromContext()`. For out-of-band metrics, one simply
needs to create and register the reporter by using `orca.Register()` and set
metrics on the returned `orca.Service` using its methods.
Copy link
Member Author

Choose a reason for hiding this comment

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

Rewrote as part of above to not have #s anymore.

examples/features/orca/client/main.go Show resolved Hide resolved
Comment on lines +47 to +50
conn, err := grpc.Dial(*addr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"orca_example":{}}]}`),
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Why? This seems like purely personal preference. We do this in other places in our examples, too, like:

roundrobinConn, err := grpc.Dial(
fmt.Sprintf("%s:///%s", exampleScheme, exampleServiceName),
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"round_robin":{}}]}`), // This sets the initial balancing policy.
grpc.WithTransportCredentials(insecure.NewCredentials()),
)

sc.Connect()

// Register a simple ORCA OOB listener on the SubConn. We request a 1
// second report interval, but in this example the minimum interval is 3
Copy link
Member Author

Choose a reason for hiding this comment

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

Done

examples/features/orca/client/main.go Show resolved Hide resolved
@dfawley dfawley assigned easwars and unassigned dfawley Mar 11, 2023
Comment on lines +47 to +48
The client performs one RPC per second. Per-RPC metrics are available for each
call via the `Done()` callback returned from the LB policy's picker.
Copy link
Contributor

Choose a reason for hiding this comment

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

Most of the other discussion here is about ORCA in general, the two types of reporting metrics, and the API in general. This line The client performs one RPC per second seems to be out of place. It seems to suddenly talk about the example.

Copy link
Member Author

@dfawley dfawley Mar 14, 2023

Choose a reason for hiding this comment

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

I don't understand. The whole section is about the example.

"The server is set up to report query cost metrics in its RPC handler. <explanation of how>"
"The client performs one RPC per second. <explanation of how it receives metrics related to those RPCs>"

Can you be more specific about how you would reword this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually looks good. Not sure what I was confused about.

Comment on lines +47 to +50
conn, err := grpc.Dial(*addr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"orca_example":{}}]}`),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

@easwars easwars assigned dfawley and unassigned easwars Mar 13, 2023
@dfawley dfawley merged commit 16c3b7d into grpc:master Mar 14, 2023
1 check passed
@dfawley dfawley deleted the orcaex branch March 14, 2023 21:01
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Documentation Documentation or examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants