• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

? Sockudo: Blazing-Fast, Pusher-Compatible WebSockets with Rust!

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Sockudo: A High-Performance WebSockets Server in Rust



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Hey Devs! ?

Are you looking for a high-performance, memory-efficient, and scalable WebSockets server that plays nicely with your existing Laravel Echo or Pusher client setup? Say hello to Sockudo! ?

Sockudo is a brand-new WebSockets server written entirely in Rust ?, designed from the ground up to be a robust and seamless replacement for services like Pusher, especially if you're in the Laravel ecosystem. It leverages Rust's incredible performance, memory safety, and concurrency features to deliver a top-notch real-time communication solution.

? Why Sockudo? What's Under the Hood?


Sockudo isn't just another WebSocket server; it's packed with features to make your real-time applications shine:

  • Full Pusher Protocol Compatibility: Drop-in replacement! Works seamlessly with Laravel Echo and other Pusher client libraries (JavaScript, Node.js, PHP, and more!).
  • Built with Rust: Get the speed, safety, and concurrency benefits of Rust for a high-throughput, low-latency experience.
  • Modular Architecture: Need to swap out components? Sockudo's design makes it easy.
  • Horizontal Scaling Out-of-the-Box: Built-in adapters for Redis, Redis Cluster, and NATS mean you can scale as your application grows.
  • Flexible App Management: Supports memory, MySQL, and DynamoDB backends for managing your application configurations.
  • Rich Channel Support: Public, private, presence, and even encrypted private channels are all supported.
  • Webhooks: Keep your application in the loop when channels become occupied or vacated. You can configure event types like member_added, member_removed, and subscription_count.
  • Performance Monitoring: Integrated Prometheus metrics endpoint (/metrics) to keep an eye on active connections, message stats, memory usage, and more.
  • Rate Limiting: Protect your server from abuse with configurable rate limiting (supports Redis).
  • Caching: Memory and Redis cache providers to speed things up.
  • Authentication: Secure your channels with robust subscription verification and user authentication.
?️ The Tech Stack


Sockudo leverages a modern and powerful stack:

  • Core: Rust
  • Scaling Adapters: Redis, Redis Cluster, NATS
  • App Management Backends: In-Memory, MySQL, DynamoDB
  • Caching: In-Memory, Redis
  • Metrics: Prometheus
  • Queueing (for webhooks, etc.): Redis, SQS
? Quick Start - Get Up and Running!


Want to take Sockudo for a spin? It's easy:

Prerequisites:

  • Rust (1.85 or newer)
  • Redis (optional, for scaling)
Clone & Build:


git clone

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


cd sockudo
cargo build --release
Run!:


./target/release/sockudo

This will start Sockudo with the default in-memory configuration.

⚙ Configuration - Tailor It to Your Needs


Sockudo is super flexible. You can configure it via a config.json file or using environment variables.

Here's a glimpse of what a config.json might look like for app management and adapter setup:


{
"app_manager": {
"driver": "memory", // Or "mysql", "dynamodb"
"array": { // Used if driver is "memory"
"apps": [
{
"id": "demo-app",
"key": "demo-key",
"secret": "demo-secret",
"max_connections": "1000", // Can be a string or number
"enable_client_messages": true,
"max_client_events_per_second": "200" // Can be a string or number
}
]
}
},
"adapter": {
"driver": "redis", // Or "nats", "local"
"redis": {
"requests_timeout": 5000,
"prefix": "sockudo",
"redis_pub_options": {
"url": "redis://127.0.0.1:6379"
},
"redis_sub_options": {
"url": "redis://127.0.0.1:6379"
}
}
},
"port": 6001, // Default WebSocket port
"metrics": {
"enabled": true,
"port": 9601 // Default metrics port
}
}

(For all available options, check out options.rs in the project!)

Or, use environment variables for quick setup:


export PORT=6001
export ADAPTER_DRIVER=redis
export REDIS_URL=redis://127.0.0.1:6379
./target/release/sockudo
? Laravel Integration? Smooth as Butter!


If you're a Laravel developer, you'll feel right at home. Just update your Laravel Echo configuration in resources/js/bootstrap.js:


// resources/js/bootstrap.js
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_PUSHER_APP_KEY,
wsHost: import.meta.env.VITE_PUSHER_HOST ?? window.location.hostname,
wsPort: import.meta.env.VITE_PUSHER_PORT ?? 6001, // Point to Sockudo's port
forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'http') === 'https',
disableStats: true,
cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1', // Sockudo uses 'mt1' as a default or your app ID
});

And your .env file:


BROADCAST_DRIVER=pusher
VITE_PUSHER_APP_ID=demo-app # Your Sockudo App ID
VITE_PUSHER_APP_KEY=demo-key # Your Sockudo App Key
VITE_PUSHER_APP_SECRET=demo-secret # Your Sockudo App Secret
VITE_PUSHER_HOST=localhost
VITE_PUSHER_PORT=6001
VITE_PUSHER_SCHEME=http
VITE_PUSHER_APP_CLUSTER=mt1 # Or your Sockudo App ID
? Works with Your Favorite Pusher Clients


Since Sockudo is Pusher-compatible, you can use standard Pusher client libraries in JavaScript, Node.js, PHP, etc., by simply pointing them to your Sockudo server instance.

Example (JavaScript):


const pusher = new Pusher('demo-key', { // Your Sockudo App Key
wsHost: 'localhost',
wsPort: 6001,
enabledTransports: ['ws', 'wss'],
disableStats: true,
forceTLS: false,
});

const channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
console.log('Received event:', data);
});
? Ready to Scale?


Sockudo is built for growth:

  • Horizontal Scaling: Easily configure the Redis or NATS adapter.
  • App Management: Use MySQL or DynamoDB for robust, production-ready app credential management.
? Dive Deeper & Contribute!


Sockudo is an open-source project licensed under AGPL 3.0. We're excited to see how the community uses and improves it!


If you're looking for a performant, modern, and highly compatible WebSocket server, especially if you're working with Rust or Laravel, give Sockudo a try. We think you'll love the speed and efficiency!


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу