承接 yadavsourabhgh/mongo-keepalive 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yadavsourabhgh/mongo-keepalive

Composer 安装命令:

composer require yadavsourabhgh/mongo-keepalive

包简介

Keep MongoDB Atlas free-tier clusters alive by sending periodic ping commands

README 文档

README

npm PyPI Crates.io NuGet RubyGems pub.dev License: MIT

Prevent MongoDB Atlas free-tier clusters from becoming inactive by periodically sending a ping command.

MongoDB Atlas pauses free-tier (M0) clusters after 60 days of inactivity. This library keeps your cluster alive by running db.adminCommand({ ping: 1 }) on a configurable interval (default: every 12 hours).

Supported Languages

Language Package Status Directory
Node.js mongo-keepalive ✅ Published node/
Python mongo-keepalive ✅ Published python/
Go mongo-keepalive/go 📦 Tag-based go/
Rust mongo-keepalive ✅ Published rust/
Java mongo-keepalive 🚧 Ready java/
PHP mongo-keepalive 🚧 Ready php/
Ruby mongo-keepalive ✅ Published ruby/
C# MongoKeepAlive ✅ Published csharp/
Dart mongo_keepalive ✅ Published dart/
Kotlin mongo-keepalive 🚧 Ready kotlin/

Status Legend:

  • ✅ Published: Available on package registry
  • 📦 Tag-based: Install via GitHub tag/module path
  • 🚧 Ready: Code complete, publishing in progress

Why Use This?

  • 🎯 Simple: One function call to keep your cluster alive
  • 🔄 Reliable: Built-in retry logic handles transient failures
  • Lightweight: Minimal memory footprint and dependencies
  • 🌍 Multi-language: Use the same solution across your entire stack
  • 🔧 Configurable: Adjust ping intervals to your needs
  • 📝 Production-ready: Comprehensive logging and error handling

Installation

Node.js

npm install mongo-keepalive

Python

pip install mongo-keepalive

Go

go get github.com/YadavSourabhGH/mongo-keepalive/go

Rust

[dependencies]
mongo-keepalive = "1.0.0"

Java / Kotlin (Maven)

<dependency>
  <groupId>com.mongokeepalive</groupId>
  <artifactId>mongo-keepalive</artifactId>
  <version>1.0.0</version>
</dependency>

PHP

composer require YadavSourabhGH/mongo-keepalive

Ruby

gem install mongo-keepalive

C#

dotnet add package MongoKeepAlive

Dart

dart pub add mongo_keepalive

Usage

Every implementation exposes a similar API:

startKeepAlive({
  uri: "mongodb+srv://user:pass@cluster.mongodb.net/db",
  interval: "12h"
})

Node.js

const { startKeepAlive } = require("mongo-keepalive");

startKeepAlive({
  uri: "mongodb+srv://user:pass@cluster.mongodb.net/db",
  interval: "12h",
});

Python

from mongo_keepalive import start_keep_alive

start_keep_alive(
    uri="mongodb+srv://user:pass@cluster.mongodb.net/db",
    interval="12h",
)

Go

package main

import keepalive "github.com/YadavSourabhGH/mongo-keepalive/go"

func main() {
    keepalive.StartKeepAlive(keepalive.Options{
        URI:      "mongodb+srv://user:pass@cluster.mongodb.net/db",
        Interval: "12h",
    })
}

Rust

use mongo_keepalive::start_keep_alive;

#[tokio::main]
async fn main() {
    start_keep_alive(
        "mongodb+srv://user:pass@cluster.mongodb.net/db",
        "12h",
    ).await;
}

Java

import com.mongokeepalive.KeepAlive;

public class Main {
    public static void main(String[] args) {
        KeepAlive.startKeepAlive(
            "mongodb+srv://user:pass@cluster.mongodb.net/db",
            "12h"
        );
    }
}

PHP

use MongoKeepAlive\KeepAlive;

KeepAlive::startKeepAlive(
    'mongodb+srv://user:pass@cluster.mongodb.net/db',
    '12h'
);

Ruby

require "mongo_keepalive"

MongoKeepAlive.start_keep_alive(
  uri: "mongodb+srv://user:pass@cluster.mongodb.net/db",
  interval: "12h"
)

C#

using MongoKeepAlive;

KeepAlive.StartKeepAlive(
    "mongodb+srv://user:pass@cluster.mongodb.net/db",
    "12h"
);

Dart

import 'package:mongo_keepalive/keepalive.dart';

void main() {
  startKeepAlive(
    uri: 'mongodb+srv://user:pass@cluster.mongodb.net/db',
    interval: '12h',
  );
}

Kotlin

import com.mongokeepalive.KeepAlive

fun main() {
    KeepAlive.startKeepAlive(
        uri = "mongodb+srv://user:pass@cluster.mongodb.net/db",
        interval = "12h"
    )
}

How It Works

  1. Connects to your MongoDB cluster using the official driver for each language.
  2. Pings the database with db.adminCommand({ ping: 1 }) at the configured interval.
  3. Retries automatically on transient failures (3 attempts with 5-second delays).
  4. Logs every ping attempt and result with timestamps.
  5. Runs efficiently — uses a single lightweight timer/scheduler with minimal memory usage.

The ping command is a lightweight operation that doesn't impact your cluster's performance but successfully registers as "activity" to prevent automatic pausing.

Configuration

Option Type Default Description
uri string MongoDB connection string (required)
interval string "12h" Ping interval (e.g. "6h", "30m")

Interval Format

  • "30m" → 30 minutes
  • "6h" → 6 hours
  • "12h" → 12 hours (default)

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feat/my-feature.
  3. Commit your changes: git commit -m "feat: add my feature".
  4. Push to the branch: git push origin feat/my-feature.
  5. Open a Pull Request.

Please ensure your code:

  • Follows the idiomatic conventions of the target language.
  • Includes logging and retry logic.
  • Does not introduce unnecessary dependencies.

Features

Cross-platform compatibility: Works across all major programming languages and ecosystems
🔐 Secure: Uses official MongoDB drivers with standard connection strings
⏱️ Flexible intervals: Configure from minutes to hours based on your needs
🛡️ Error resilient: Automatic retry logic with exponential backoff
📊 Observable: Built-in logging for monitoring and debugging
🚀 Zero-config defaults: Works out of the box with sensible 12-hour interval
♻️ Graceful shutdown: Clean stop mechanisms in all implementations
🎨 Idiomatic code: Each language implementation follows best practices and conventions

FAQ

Q: Will this increase my MongoDB Atlas costs?
A: No. The ping command is extremely lightweight and doesn't count against your storage or compute quotas. Free-tier clusters remain free.

Q: How often should I ping?
A: The default 12-hour interval is recommended. This is frequent enough to prevent inactivity while minimizing unnecessary operations.

Q: Can I use this in production?
A: Yes! All implementations include proper error handling, logging, and retry logic suitable for production use.

Q: Does this work with paid MongoDB Atlas tiers?
A: Yes, but it's primarily designed for free-tier (M0) clusters which auto-pause after 60 days of inactivity.

Q: What happens if my internet connection drops?
A: The library will retry failed pings automatically and continue when connectivity is restored.

Links

License

This project is licensed under the MIT License.

yadavsourabhgh/mongo-keepalive 适用场景与选型建议

yadavsourabhgh/mongo-keepalive 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「mongodb」 「maintenance」 「automation」 「cluster」 「ping」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yadavsourabhgh/mongo-keepalive 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yadavsourabhgh/mongo-keepalive 我们能提供哪些服务?
定制开发 / 二次开发

基于 yadavsourabhgh/mongo-keepalive 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 34
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-04