https://github.com/joshnuss/xuber2
An example ridesharing app built with Elixir
https://github.com/joshnuss/xuber2
actor-model elixir geolocation
Last synced: 6 months ago
JSON representation
An example ridesharing app built with Elixir
- Host: GitHub
- URL: https://github.com/joshnuss/xuber2
- Owner: joshnuss
- Created: 2017-12-13T19:08:36.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-22T13:45:33.000Z (almost 7 years ago)
- Last Synced: 2025-04-11T21:52:33.511Z (6 months ago)
- Topics: actor-model, elixir, geolocation
- Language: Elixir
- Homepage:
- Size: 93.8 KB
- Stars: 28
- Watchers: 4
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# XUber
A reference design for a ride sharing application (similar to Uber & Lyft)
## Overview
Ride sharing apps are uniquely suited to Elixir/Erlang because the are:
- **Asynchronous**: examples of async operations are passenger requesting a ride, drivers notifying the server of their locations, broadcasting a driver's coordinates to mutiple passengers.
- **Parallel**: Millions of peers can be connected simultaneously (theoretically, not yet benchmarked).
- **Soft-realtime**: Communication between drivers & passengers occur in near realtime (subsecond).
- **Full-duplex**: Phoenix supports full-duplex WebSockets between mobile device and cloud.
- **Fault tolerance**: Failures do no propagate. For example a exception in a specific ride cannot effect another, same goes for a node, cell and data center.
- **Resiliency**: Failures can have backup plans. For example, if a driver is not responding to a pickup request, a different driver can be dispatched.
- **Multi DC**: The management of drivers and passengers is sharded geographically (like a cell phone network). If failure occurs in a specific geographic region, other regions are unaffected.## Installation
```bash
hub clone joshnuss/xuber2
cd xuber2
mix do deps.get, ecto.create, ecto.migrate
```## Running examples
```
mix run --no-halt examples/basic.exs
```## Actual log data
```
Passenger `mary` has joined at coordinates {10, 10}
Driver `tom` has joined at coordinates {10, 10}
Driver `tom` has indicated they are available
Passenger `mary` is searching for drivers within 5km of coordinates {10, 10}
Passenger `mary` found drivers: `tom` @distance=0.0km
Passenger `mary` is searching for drivers within 5km of coordinates {10, 10}
Passenger `mary` found drivers: `tom` @distance=0.0km
Passenger `mary` is searching for drivers within 5km of coordinates {10, 10}
Passenger `mary` found drivers: `tom` @distance=0.0km
Passenger `mary` has requested a pickup at coordinates {10, 10}
Dispatcher received request for pickup at {10, 10} for `mary`
Dispatcher assigned driver `tom` to pickup `mary`
Driver `tom` has been notified to pickup passenger `mary`, pickup #PID<0.878.0>
Passenger `mary` has been notified that driver `tom` will pick them up, pickup #PID<0.878.0>
Driver `tom` has moved to coordinates {10, 15}
Driver `tom` has moved to coordinates {10, 16}
Driver `tom` has arrived at destination {10, 16}
Ride #PID<0.879.0> has started for passenger `mary` and driver `tom`
Driver `tom` has departed, ride #PID<0.879.0>
Passenger `mary` has been picked up and is departing with ride #PID<0.879.0>
Ride #PID<0.879.0> is at {10, 16}
Driver `tom` has moved to coordinates {10, 16}
Ride #PID<0.879.0> is at {10, 16}
Passenger `mary` has moved to coordinates {10, 16}
Driver `tom` has moved to coordinates {10, 17}
Ride #PID<0.879.0> is at {10, 17}
Passenger `mary` has moved to coordinates {10, 17}
Ride #PID<0.879.0> is at {10, 17}
Ride #PID<0.879.0> is at {10, 18}
Driver `tom` has moved to coordinates {10, 18}
Passenger `mary` has moved to coordinates {10, 18}
Ride #PID<0.879.0> is at {10, 18}
Passenger `mary` has arrived at destination {10, 18}
Driver `tom` has dropped off passenger `mary` at coordinates {10, 18}
Ride #PID<0.879.0> has been completed. Dropoff location was {10, 18}
Passenger `mary` has gone offline
Driver `tom` has indicated they are unavailable
Driver `tom` has gone offline
```