Skip to content

Commit

Permalink
⚡️ Test a better load balancing split
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Jul 10, 2024
1 parent a34ff2f commit cc2c65c
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions ponder.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ import {
import { contentRegistryAbi } from "./abis/frak-registry-abis";
import { multiWebAuthNValidatorV2Abi } from "./abis/multiWebAuthNValidatorABI";


/**
* @description Creates a load balanced transport that spreads requests between child transports using a round robin algorithm.
*/
export function timestampLoadBalance(_transports: Transport[]): Transport {
return ({chain, retryCount, timeout}) => {
return ({ chain, retryCount, timeout }) => {
const transports = _transports.map((t) =>
chain === undefined
? t({retryCount: 0, timeout})
: t({chain, retryCount: 0, timeout})
? t({ retryCount: 0, timeout })
: t({ chain, retryCount: 0, timeout })
);

return createTransport({
Expand Down Expand Up @@ -56,8 +55,8 @@ export function timestampLoadBalance(_transports: Transport[]): Transport {
}

const pollingConfig = {
pollingInterval: 20_000,
maxRequestsPerSecond: 16,
pollingInterval: 15_000,
maxRequestsPerSecond: 24,
} as const;

export default createConfig({
Expand All @@ -72,10 +71,22 @@ export default createConfig({
chainId: 421614,
transport: timestampLoadBalance([
http(
`https://arb-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`
`https://arb-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`,
{
retryCount: 0,
}
),
http(
`https://arbitrum-sepolia.blockpi.network/v1/rpc/${process.env.BLOCKPI_API_KEY_ARB_SEPOLIA}`,
{
retryCount: 0,
}
),
http(
`https://arbitrum-sepolia.blockpi.network/v1/rpc/${process.env.BLOCKPI_API_KEY_ARB_SEPOLIA}`
`https://arb-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`,
{
retryCount: 0,
}
),
]),
...pollingConfig,
Expand Down

0 comments on commit cc2c65c

Please sign in to comment.