Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

I replaced $700/month of SaaS with Google Apps Script. Here’s what broke first.

Описание и применение

Автор заменил дорогую SaaS‑систему на Google Apps Script, но столкнулся с проблемами при росте нагрузки. Оптимизировав код: использовал пакетные записи, кэш для идемпотентности, блокировки для конкуренции и контроль времени выполнения, он избавился от ошибок и затрат.

Задача

High monthly SaaS costs for simple data transfer and arithmetic were replaced with a Google Apps Script solution that initially failed under higher load.

Результат

The refactored script runs without hitting service quotas, avoids duplicate writes, prevents data loss from concurrent executions, and respects the 6‑minute execution limit, eliminating the $700/month SaaS expense.

Рабочий процесс

  • 1. Replace per‑row appendRow calls with a single setValues batch write.
  • 2. Implement idempotency using CacheService to dedupe webhook events.
  • 3. Use LockService.getScriptLock() to serialize writes and avoid race conditions.
  • 4. Add checkpointing logic to stop processing before the 6‑minute runtime limit and schedule continuation via triggers.

Доказательства

One call instead of four hundred: ... setValues(rows);

Источник

CacheService is the right tool here rather than PropertiesService

Источник

LockService.getScriptLock() rather than getUserLock()

Источник

Apps Script kills any execution at six minutes

Источник

  • Дата записи: 2026-09-20T02:00:21.200Z