Easy Deployment and Operations

Design enabling auto-deployment to cloud and scalability

DeploymentCloudScalabilityOperationsConfiguration Management
4 min read

About This Topic

Systems don't end when they're built—continuing to operate them is what matters. This project focused on designs that minimize effort from deployment through operations.

Auto-Deployment to Cloud

Just upload source code, and it's automatically deployed to the cloud environment.

Deployment Flow
Push Code

Developer sends code to Git repository

Auto-Detection

Cloud platform detects changes

Build

Install dependencies, compile

Deploy

Roll out new version

Health Check

Verify normal operation and complete

Auto-Deployment Benefits

No server provisioning
DescriptionNo physical servers or VPS needed
Reduced setup effort
DescriptionNo OS or middleware configuration
Immediate reflection
DescriptionMinutes from code push to production
Rollback capability
DescriptionCan revert to previous version if issues

Auto-Scaling

Even as usage increases, the cloud automatically adjusts resources.

Scaling Mechanism
Quiet Period

Minimal configuration for cost savings. 1 instance handles processing

Access increases
Normal Period

2-3 instances process in parallel

Month-end busy period
Busy Period

Automatically scale out. Distribute request processing

Scaling Points

Night/Weekend
Instance CountMinimum (0-1)
ResponseMinimize cost
Normal business hours
Instance Count2-3
ResponseStable response
Month-end aggregation
Instance CountAuto-increase
ResponsePrevent processing delays

Configuration via Environment Variables

Settings are managed through environment variables. Adjust behavior without changing code.

Required Settings

RUN_TOKEN
DescriptionSecret token for authentication
Example32+ character string
FREEE_CLIENT_ID
DescriptionInvoicing service client ID
ExampleID issued by API
FREEE_CLIENT_SECRET
DescriptionInvoicing service client secret
ExampleSecret key issued by API
FREEE_REFRESH_TOKEN
DescriptionRefresh token for token renewal
ExampleToken issued by API

Optional Settings (with defaults)

RATE_LIMIT_PER_MINUTE
DescriptionRequest limit per minute
Default60
CONCURRENT_FREEE_CALLS
DescriptionConcurrent API calls
Default2
RETRY_MAX_ATTEMPTS
DescriptionMaximum retry attempts
Default5
REQUEST_TIMEOUT_MS
DescriptionTimeout (milliseconds)
Default30000

Testing Settings

FREEE_DRY_RUN
DescriptionDry-run mode (true/false)
PurposeTest without production send
ENABLE_STRUCTURED_LOGGING
DescriptionDetailed log output (true/false)
PurposeEnable during debugging

Timeout Settings

Appropriate timeouts are set for long-running processes.

Timeout Control
Request Starts

Begin processing, set timer

Execute Processing

Run API calls, etc.

Timeout Check

Exceeded set time?

Within time
Return result normally
Exceeded
Abort processing, return error

Timeout Setting Guidelines

Single API call
Recommended30 seconds
ReasonUsually completes in seconds
Batch (~100 items)
Recommended2 minutes
ReasonAccount for paging
Large scale (~500 items)
Recommended5 minutes
ReasonUse cloud's full limit

Distributed Cache Utilization

Using Redis (Upstash) distributed cache enables:

Idempotency cache
DescriptionKeep processed keys for 7 days
BenefitShared across instances
Token cache
DescriptionKeep access token until expiry
BenefitReduce API calls
Distributed lock
DescriptionPrevent concurrent updates
BenefitEnsure data consistency

Operations Checklist

Before Deployment

  • [ ] All required environment variables set?
  • [ ] Verified operation in dry-run mode?
  • [ ] Token expiry sufficient?

During Operations

  • [ ] Check error logs periodically
  • [ ] Rate limit not being reached?
  • [ ] Response times normal?

During Trouble

  • [ ] Identify problem area with structured logs
  • [ ] Switch to dry-run mode if needed
  • [ ] Test single item after configuration changes

What This Design Achieves

For Operations

  • Minimize deployment cost: No servers, minimal configuration
  • Reduce operational load: Auto-scaling, auto-deployment
  • Flexible adjustment: Customize behavior via environment variables

For Field Staff

  • Stable service: No delays even at month-end
  • Immediate usability: No complex setup
  • Easy problem response: Understand situation via logs and health checks

Related Topics