Azure Cache for Redis - Horizontal scaling

Jabber6 months ago

Hi team,

Firstly, thank you to you and your team / contributors for a great product!

I'm wondering if you would be able to assist with an issue I'm struggling with using Azure Cache for Redis for broadcasts.

Some background on my current setup:

  • I've setup 2x Azure VM's running Traccar 5.12 which form part of a load balancer for horizontal scaling.
  • Web access has been disabled on both VM's as it's not required. No other application features are in use (events, notifications, smtp, sms, etc.).
  • Inbound device data is being persisted to a SQL db.
  • I have Azure Cache for Redis configured and only accept requests using SSL on port 6380 using TLS 1.2.

I've added the following configuration to both VM's and restarted the Traccar services.

    <entry key='broadcast.type'>redis</entry>
    <entry key='broadcast.address'>rediss://default:<password>@<hostname>.redis.cache.windows.net:6380/0</entry>

I'm however not able to see any data being added to the respective Redis db. There are no errors in the Traccar log files indicating any connection / broadcast issues. The Azure Cache for Redis instance has no firewall restrictions in place that would be blocking traffic from the VMs.

As a test, I've also configured position forwarding to use Redis and data is being added to the respective db - this therefore confirms there are no infrastructure restrictions in place blocking access.

    <entry key='forward.type'>redis</entry>
    <entry key='forward.url'>rediss://default:<password>@<hostname>.redis.cache.windows.net:6380/1</entry>

I've gone as far as adding additional logging to RedisBroadcastService to confirm messages are being published.

2024-05-16 03:24:14  INFO: RedisBroadcastService.updateDevice - publishing payload: d13a30ac-95db-471f-ac14-c1a2d51b0517:{"device":{"id":7823,"attributes":{},"groupId":0,"calendarId":0,"name":"_MASKED_","uniqueId":"_MASKED_","status":"online","lastUpdate":"2024-05-16T03:24:14.898+00:00","positionId":855656226,"phone":null,"model":null,"contact":null,"category":null,"disabled":false,"expirationTime":null},"position":null,"userId":null,"event":null,"commandDeviceId":null,"invalidateObject":null,"invalidatePermission":null}
2024-05-16 03:24:14  INFO: RedisBroadcastService.updateDevice - Is publisher connected: true
2024-05-16 03:24:14  INFO: RedisBroadcastService.updateDevice - Message published. Is publisher connected: true
2024-05-16 03:24:14  INFO: RedisBroadcastService.onMessage - Subscriber message received: d13a30ac-95db-471f-ac14-c1a2d51b0517:{"device":{"id":7823,"attributes":{},"groupId":0,"calendarId":0,"name":"_MASKED_","uniqueId":"_MASKED_","status":"online","lastUpdate":"2024-05-16T03:24:14.898+00:00","positionId":855656226,"phone":null,"model":null,"contact":null,"category":null,"disabled":false,"expirationTime":null},"position":null,"userId":null,"event":null,"commandDeviceId":null,"invalidateObject":null,"invalidatePermission":null}
2024-05-16 03:24:15  INFO: Event id: _MASKED_, time: 2024-05-16 03:24:12, type: ignitionOn, notifications: 0
2024-05-16 03:24:15  INFO: RedisBroadcastService.updatePosition - publishing payload: d13a30ac-95db-471f-ac14-c1a2d51b0517:{"device":null,"position":{_MASKED_},"deviceId":7823,"protocol":"_MASKED_","serverTime":"2024-05-16T03:24:14.898+00:00","deviceTime":"2024-05-16T03:24:12.000+00:00","fixTime":"2024-05-16T03:24:12.000+00:00","outdated":false,"valid":true,"latitude":_MASKED_,"longitude":_MASKED_,"altitude":-37.0,"speed":0.0,"course":299.0,"address":null,"accuracy":0.0,"network":null,"geofenceIds":null},"userId":null,"event":null,"commandDeviceId":null,"invalidateObject":null,"invalidatePermission":null}
2024-05-16 03:24:15  INFO: RedisBroadcastService.updatePosition - Is publisher connected: true
2024-05-16 03:24:15  INFO: RedisBroadcastService.updatePosition - Message published. Is publisher connected: true

Questions I have are:

  • Is there any additional configuration required that I may have missed for broadcasting to Redis?
  • Seeing as I'm not making use of the Web, or any other underlying features (notifications, events etc.) of the application other than to persist device data to a database, is broadcasting required for horizontal scaling?
Anton Tananaev6 months ago

Redis is used for broadcasting messages. We don't really persist anything there.

If you're just using Traccar store data in the database and nothing else, you might not even need horizontal scaling.

Jabber6 months ago

Hi Anton,

Thank you for the reply.

The reason for wanting to add additional servers is for load balancing and redundancy.

Having read through other forum posts, I am under the impression (possibly incorrectly) that having two or more servers requires multicast or Redis. Is this only necessary when using the Traccar web interface?

Anton Tananaev6 months ago

It depends. If you just need raw decoded data, you probably don't need it.