Hello, is there a way for me to connect to redis private service?

I want to use the redis-cli on my private service on render, is there a way to connect to it from my machine, or since it’s a private service I can only connect to in from other services that I have on render?

I need to flush all present (queue) keys, since It’s already taking too much memory?

If there is no way to connect to it, can you give me some suggestions as to how to flush render redis DB?

Thanks

Hi @dameradev ,

If you’ve deployed redis using these instructions, redis-cli is already installed on your private service. You can access it by clicking on the “Shell” tab of your private service, and typing redis-cli at the prompt.

If the private service is listening on port 10000, you also have to specify the port value like so redis-cli -p 10000 since redis-cli, by default, assumes that redis is listening on port 6379.

Let me know if you have more issues using redis-cli!

How are you able to access redis from other services? I’m trying to wrap my head around this part of the instructions

Once deployed, your Redis instance will be available on a URL similar to redis:10000, and you can start using your Redis URL from other services in your Render account.

So 2 questions.

  1. I tried to access the internal url from another service in my account, BUT, when I shelled into that other service, it didn’t have the redis-cli installed. So no luck to run redis-cli . How do I access redis from other services then?
  2. How would I define the redis url for other linked services to consume? At least for a database I can do something like this with the envVars fromDatabase yaml stuff. How do I do that with Redis?
databases:
- name: group_service1_postgres_db
  databaseName: group_service1
  user: test_user
  plan: free
services:
- name: group_service1_backend
  repo: https://github.com/snackattas/group_service1.git
  type: web
  plan: free
  env: node
  buildCommand: yarn build-backend
  startCommand: yarn start-backend
  envVars:
  - key: MY_DATABASE_URL
    fromDatabase:
      name: group_service1_postgres_db
      property: connectionString
      envVarKey: DATABASE_URL

Would you have to do something like this?

- type: pserv
  name: redis
  env: docker
  disk:
    name: data
    mountPath: /var/lib/redis
    sizeGB: 10
- type: node
  name: servicethatusesredis
  envVars:
  - key: REDIS_SERVICE_NAME
    fromService:
      type: pserv
      name: redis
      envVarKey: RENDER_SERVICE_NAME
  - key: REDIS_PORT
    fromService:
      type: pserv
      name: redis
      envVarKey: PORT

And then have a start command for the service that creates the redis internal url from the PORT and RENDER_SERVICE_NAME?

Hi @snackattas,

Thanks for reaching out! I’d like to confirm that you’ve deployed Redis as a private service. You are not using Render’s Managed Redis in EA.

If so, these will be the answers to your questions:

  1. I tried to access the internal url from another service in my account, BUT, when I shelled into that other service, it didn’t have the redis-cli installed. So no luck to run redis-cli . How do I access redis from other services then?

redis-cli will be available through the shell tab of your redis service. To connect to redis from other services, you can hardcode the service address as found on the dashboard in the screenshot from the docs here as an environment variable.

  1. How would I define the redis url for other linked services to consume? At least for a database I can do something like this with the envVars fromDatabase yaml stuff. How do I do that with Redis?

If you’d prefer to do that through blueprint, you would do:

- type: pserv
  name: redis
  env: docker
  disk:
    name: data
    mountPath: /var/lib/redis
    sizeGB: 10
- type: node
  name: servicethatusesredis
  envVars:
  - key: REDIS_HOST_PORT
    fromService:
      type: pserv
      name: redis
      property: hostport

And then yes, in your start command, you would want to prepend redis:// to the environment variable REDIS_HOST_PORT if your node service expects the url to be in that form.

Let me know if you have any other questions!

So, let’s say the hostport is 10000

would the url I use in the other service be:
redis://10000
redis://localhost:10000
redis://redis-pr-2-5vnv:10000 (this comes from the env var RENDER_SERVICE_NAME)

If it does need to know the RENDER_SERVICE_NAME, then, really, it needs 2 env vars, not just the REDIS_HOST_PORT, right?

So sorry for the late reply @snackattas ! I just saw your reply.

hostport does not resolve to be 10000. It resolves to be the combination of the host (ex. redis-pr-2-5vnv), a colon : and the port (ex: 10000). So all you need is REDIS_HOST_PORT with redis:// in front of it. Here is a link to the docs that detail this.

Hope this helps!