Skip to content

Conversation

@filipecabaco
Copy link
Member

What kind of change does this PR introduce?

currently we have fly and aws very hardcoded so we need to reduce that by changing the way we setup realtime to be less locked to this ecosystems

the first we are focusing on read replicas which is very hard coded to our infrastructure.

for read replicas you can set:

export DB_HOST_REPLICA_HOST_us-east-1='127.0.0.1'
export DB_HOST_REPLICA_TARGET_REGIONS_us-east-1='us-east-1,us-east-2,us-east-3'

which will setup the us-east-1 read replica and inform realtime that the regions us-east-1,us-east-2,us-east-3 should use this read replica. if not, they will use the default repo.

@vercel
Copy link

vercel bot commented Aug 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
realtime-demo Ignored Ignored Aug 26, 2025 0:06am

currently we have fly and aws very hardcoded so we need to reduce that by changing the way we setup realtime to be less locked to this ecosystems

the first we are focusing on read replicas which is very hard coded to our infrastructure.
@filipecabaco filipecabaco force-pushed the feat/remove-platform-settings branch from fc11195 to 9231dd8 Compare August 26, 2025 12:06
connect_partition_slots = Env.get_integer("CONNECT_PARTITION_SLOTS", System.schedulers_online() * 2)
metrics_cleaner_schedule_timer_in_ms = Env.get_integer("METRICS_CLEANER_SCHEDULE_TIMER_IN_MS", :timer.minutes(30))
metrics_rpc_timeout_in_ms = Env.get_integer("METRICS_RPC_TIMEOUT_IN_MS", :timer.seconds(15))
rebalance_check_interval_in_ms = Env.get_integer("REBALANCE_CHECK_INTERVAL_IN_MS", :timer.seconds(10))
Copy link
Member

Choose a reason for hiding this comment

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

this one should be :timer.minutes(10)

connect_partition_slots = Env.get_integer("CONNECT_PARTITION_SLOTS", System.schedulers_online() * 2)
metrics_cleaner_schedule_timer_in_ms = Env.get_integer("METRICS_CLEANER_SCHEDULE_TIMER_IN_MS", :timer.minutes(30))
metrics_rpc_timeout_in_ms = Env.get_integer("METRICS_RPC_TIMEOUT_IN_MS", :timer.seconds(15))
rebalance_check_interval_in_ms = Env.get_integer("REBALANCE_CHECK_INTERVAL_IN_MS", :timer.seconds(10))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rebalance_check_interval_in_ms = Env.get_integer("REBALANCE_CHECK_INTERVAL_IN_MS", :timer.seconds(10))
rebalance_check_interval_in_ms = Env.get_integer("REBALANCE_CHECK_INTERVAL_IN_MS", :timer.minutes(10))

# 4 hours by default
janitor_schedule_timer = System.get_env("JANITOR_SCHEDULE_TIMER_IN_MS", "14400000") |> String.to_integer()
# defaults to 10 minutes
Env.get_integer("DISCONNECT_SOCKET_ON_NO_CHANNELS_INTERVAL_IN_MS", :timer.seconds(30))
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this disconnect_socket_on_no_channels_interval_in_ms is being used at all. Should we just remove it?

config :realtime, run_janitor: false
else
if config_env() != :test && run_janitor? do
config :realtime,
Copy link
Member

Choose a reason for hiding this comment

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

Where we are setting run_janitor: false when run_janitor? is false?

url: [host: "#{app_name}.supabase.co", port: 443],
http: [
compress: true,
port: Env.get_integer("PORT", 443),
Copy link
Member

Choose a reason for hiding this comment

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

port was 4000 before here


config :realtime, RealtimeWeb.Endpoint,
server: true,
url: [host: "#{app_name}.supabase.co", port: 443],
Copy link
Member

Choose a reason for hiding this comment

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

it was 80 here

export DB_HOST_REPLICA_TARGET_REGIONS_us-east-1='us-east-1,us-east-2,us-east-3'
```

This will inform realtime that nodes connected to the `us-east-1` region will be able to connect to the replica database for the `us-east-1` region. If the region is not specified, the we will set the main repository as the default.
Copy link
Member

Choose a reason for hiding this comment

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

how us-east-1 and us-east-2 etc are used in this example

If the region is not specified, the we will set the main repository as the default.

*then ?

region_mapping(platform, tenant_region)
end

defp region_mapping(:aws, tenant_region) do
Copy link
Member

Choose a reason for hiding this comment

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

Should this be configured through the ENV vars as well? (Not in this PR but in the future?)

Copy link
Member Author

Choose a reason for hiding this comment

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

yes it will be just wanted to make it in a different PR but it will be similar to the existing one 👀

Copy link
Member

@edgurgel edgurgel left a comment

Choose a reason for hiding this comment

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

Added some comments but other than that LGTM. Nice one making this more generic!

@filipecabaco
Copy link
Member Author

#1511

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