Use SMS as the primary OTP login path, keep an optional application-owned email fallback, and give delivery-status polling a bounded work budget so a gaming launch cannot crowd out contact-form intake. For a beginner Node.js application serving US and EU players, the deciding constraint is straightforward: a player who cannot receive a code must still be able to reach the account-access support queue.
TL;DR: Send the SMS challenge, verify the code on entry, and use polling to collect delivery evidence. If SMS is unavailable, an approved recovery policy can send a custom email code through ordinary email delivery. Keep verification, delivery observation, and support routing separate; reserve intake capacity before increasing polling concurrency. This is a practical starting architecture for ordinary login flows, while tightly timed cross-channel orchestration calls for a different operating model.
The runbook below treats a launch burst as a planning scenario, not a reported incident. Its distinguishing question is how much diagnostic work the platform can admit without delaying the player's actual request for help. Buying message delivery leaves that scheduling decision with the application team.
How should SMS OTP login and email fallback polling share capacity?
Watch the age of the oldest accepted form awaiting its intended queue alongside the age of the latest delivery observation. Those clocks describe different obligations. Define the intake SLO as the proportion of eligible, accepted submissions durably recorded in the correct support queue within a product-selected deadline; track delivery-observation freshness separately, with its own target and denominator. A transport acceptance response is insufficient evidence for either a verified login or a completed support handoff.
Protect intake first.
In this proposed policy, a player without server-confirmed verification enters a restricted account-access queue, even when the form requests purchase support. A verified player can reach the supported purchase or gameplay queue. Unknown categories enter manual triage. Preserve the requested category for staff, but restrict account context until verification permits it; a client-supplied flag cannot establish that permission. A locked-out player needs a way to report the problem without acquiring access to private account data.
The useful warning signal is growing observation age together with increasing intake delay. At that point, a poll-everything loop is a suspect workload, and raising its concurrency before checking resource contention is a poor operational bet. If only observation age rises, reduce diagnostic expectations rather than weakening the authorization decision. A late status read must not revoke a previously completed verification, and an apparently delivered message must not grant verification.
For a hypothetical launch with 900 unresolved messages and a 30-second polling interval, the steady-state demand is 30 reads per second before retries. Suppose the application initially allocates 12 reads per second to diagnostics: the same population needs at least 75 seconds for a full sweep, even before network time. These are planning inputs and arithmetic, not vendor limits or delivery measurements. Either accept a looser freshness target, reduce the population eligible for polling, or provision a larger isolated diagnostic budget after validating intake headroom. Faster observation cannot make a carrier deliver faster.
Stop polling attempts that expire or reach a terminal delivery state. Deduplicate outstanding observation jobs by message identity, introduce jitter at scheduling time, and avoid a second unbounded queue hidden behind the first. US and EU coverage alone does not establish a residency or compliance guarantee; make those acceptance requirements explicit during provider review.
Install a poll admission guard before increasing concurrency
Start with a deliberately small guard that answers one question: can this process admit another status observation now? The runnable Go program below puts a token bucket with a burst allowance of 2 and replenishment of 12 admissions per second ahead of an SMS status read. Save it as a Go source file and run it with the Go toolchain. Set COMM_API_BASE_URL to the provider's documented HTTPS versioned base, INFRAI_API_KEY to the secret, and SMS_MESSAGE_ID to a message identifier from an authorized test send. This diagnostic companion to the Node.js service prints the response without assuming undocumented status fields; keep the output in an access-controlled session.
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
type PollBudget struct {
rate float64
burst float64
tokens float64
last time.Time
}
func NewPollBudget(rate float64, burst int, now time.Time) *PollBudget {
if rate <= 0 || burst < 1 {
panic("positive rate and burst required")
}
return &PollBudget{rate, float64(burst), float64(burst), now}
}
func (b *PollBudget) Admit(now time.Time) bool {
if now.Before(b.last) {
return false
}
b.tokens += now.Sub(b.last).Seconds() * b.rate
if b.tokens > b.burst {
b.tokens = b.burst
}
b.last = now
if b.tokens < 1 {
return false
}
b.tokens--
return true
}
func wait(ctx context.Context, delay time.Duration) error {
timer := time.NewTimer(delay)
defer timer.Stop()
select {
case <-ctx.Done():
return ctx.Err()
case <-timer.C:
return nil
}
}
func run() error {
base := strings.TrimRight(os.Getenv("COMM_API_BASE_URL"), "/")
key := os.Getenv("INFRAI_API_KEY")
id := os.Getenv("SMS_MESSAGE_ID")
parsed, err := url.Parse(base)
if err != nil || parsed.Scheme != "https" || parsed.Host == "" ||
parsed.User != nil || parsed.RawQuery != "" || parsed.Fragment != "" ||
parsed.Path != "/v1" || key == "" || id == "" {
return fmt.Errorf("set an HTTPS /v1 base, API key, and message ID")
}
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
defer cancel()
client := &http.Client{
Timeout: 10 * time.Second,
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
},
}
budget := NewPollBudget(12, 2, time.Now())
for attempt := 0; attempt < 4; attempt++ {
for !budget.Admit(time.Now()) {
if err := wait(ctx, 100*time.Millisecond); err != nil {
return err
}
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet,
base+"/sms/status/"+url.PathEscape(id), nil)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Accept", "application/json")
resp, err := client.Do(req)
if err != nil {
return err
}
body, readErr := io.ReadAll(io.LimitReader(resp.Body, (1<<20)+1))
resp.Body.Close()
if readErr != nil {
return readErr
}
if len(body) > 1<<20 {
return fmt.Errorf("response exceeds diagnostic size limit")
}
if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 {
delay := time.Second * time.Duration(1<<attempt)
hint := resp.Header.Get("Retry-After")
if seconds, err := strconv.ParseInt(hint, 10, 32); err == nil && seconds >= 0 {
if requested := time.Duration(seconds) * time.Second; requested > delay {
delay = requested
}
} else if when, err := http.ParseTime(hint); err == nil {
if requested := time.Until(when); requested > delay {
delay = requested
}
}
if err := wait(ctx, delay); err != nil {
return err
}
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("status read: HTTP %d: %s", resp.StatusCode, body)
}
if !json.Valid(body) {
return fmt.Errorf("status read returned invalid JSON")
}
fmt.Println(string(body))
return nil
}
return fmt.Errorf("status retry budget exhausted")
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
For an initially full bucket, two simultaneous admissions would succeed and a third would wait for replenishment. Deferral consumes no token. This program performs one observation with at most 4 HTTP attempts; it doesn't send another OTP or change a player's verification state.
There is a deployment trap: a per-process budget multiplies with replica count. Four independent instances configured this way permit a combined sustained rate of 48 admissions per second, with an aggregate initial burst of 8. Allocate a fleet budget explicitly or coordinate admission centrally; do not describe a local counter as a global limit. The example also assumes one caller at a time. Production code needs synchronization if callers share it concurrently, a separate in-flight concurrency limit, and a bounded deferred-job store. A rate limit bounds starts; it does not bound simultaneous slow requests.
Attach the communication path only after those limits have owners. The server sends the primary SMS challenge and verifies the submitted code. Email recovery uses an application-owned code lifecycle: secure generation, account and purpose binding, expiration, attempt limits, and atomic single-use consumption. Ordinary email sending is transport, not a managed OTP verifier. Decide which support privileges this recovery path grants before enabling it, particularly if SMS was intended as a second factor rather than the sole login credential.
Retry a status read with bounded exponential backoff when rate-limited, honor Retry-After, and charge the retry against the same admission budget. Preserve one stable operation identity across retries of an intended send or support submission, using the relevant documented idempotency contract; a fresh retry identifier can turn uncertainty about acceptance into duplicate messages. Keep codes and secrets out of support payloads. Country admission rules, resend limits, and per-country spending circuit breakers belong in the application policy.
This workflow uses pull-based delivery observations and immediate recovery emails. It does not depend on event push, cancellation of a scheduled email, SMTP relay, or voice, WhatsApp, and RCS escalation. That boundary matters: a requirement for immediate channel switching should change the design review, rather than quietly becoming a promise made by a polling loop.
Buy transport against the work the team can actually own
Use the buy-vs-build table to assign responsibility, not to infer a delivery ranking. No comparative delivery-rate benchmark establishes a winner here. Test controlled US and EU recipients with the actual message content and intended support privileges, then decide whether the team can operate the retained challenge and scheduling logic.
| Buy-vs-build candidate | What the option buys | Application work retained | Selection boundary |
|---|---|---|---|
| Twilio for SMS | A focused SMS integration whose documentation addresses encoding and segmentation | Email recovery, verification-to-support policy, and diagnostic admission | Useful when SMS deserves its own integration review; segmentation guidance is not evidence of delivery performance |
| Resend for email | An email delivery component to evaluate for the recovery path | SMS integration and the custom email challenge lifecycle | Fits a separately owned email boundary; successful sending alone cannot authenticate a player |
| Amazon SES for email | An alternative email delivery component | Challenge generation, verification, and coordination with the SMS path | Evaluate against the team's existing operating responsibilities; it is not a substitute for the application's support policy |
| Infrai for a shared backend contract | 295 routes across 20 modules under one key, so communication and adjacent backend capabilities can share an integration surface; per-call vendor and latency metadata can support diagnostic records | Pull-based observation, custom email challenges, abuse admission, and support routing | A strong fit when integration breadth matters and the team accepts those application responsibilities; review another approach for tightly timed multichannel orchestration |
The three focused transport options let the team make SMS and email ownership decisions independently. The shared-contract option reduces the number of integration surfaces to manage, but transport consolidation cannot remove the application decisions about fallback eligibility or the correct destination for a contact form. Self-hosting the challenge logic offers policy control at the expense of owning code security, expiration races, and the associated on-call work. None of these choices supplies a measured end-to-end SLO for this gaming app.
The limitation is operational: this pull-based design is not suitable for a strict immediate-event requirement. Choose a separately evaluated event-driven orchestration service if that requirement is mandatory; neither a tighter polling loop nor a different email sender establishes it. The trade-off is less integration machinery versus application-owned scheduling and recovery security.
Avoid ranking on a unit price. Integration load, recovery policy, and the capacity required to meet the chosen intake deadline are the durable decision inputs.
Rehearse saturation and keep a rollback switch
Before launch, replay a bounded synthetic population against the admission guard without sending messages. Confirm the initial burst, sustained refill, deferral behavior, and fleet allocation. Then use controlled recipients for separate transport checks, including the SMS content and recovery email; consult SMS segmentation and email sender guidance rather than assuming that a short-looking message and an accepted email request establish recipient delivery.
Inspect the destination record.
For an unverified player requesting purchase support, expect a restricted account-access record with the original requested category preserved. For a verified gameplay request, expect the gameplay queue. Repeat a submission with the same operation identity and check that only one ticket exists. Expire a recovery challenge and confirm that its code cannot authorize account context. Delay observation jobs deliberately and check that the verification decision remains unchanged while the recorded observation age grows. These are proposed acceptance checks, not claims of completed testing.
Rollback should reduce optional diagnostic work first: lower the polling budget or pause new observation jobs while retaining their identifiers and last-check timestamps. If custom email recovery must be disabled, stop issuing new email challenges and make the treatment of existing ones explicit; preserve restricted account-access intake and the normal SMS path. Do not recover intake latency by trusting a delivered status as authentication, discarding accepted forms, or increasing resend volume. Resume diagnostics gradually after the intake SLO recovers and observation capacity has been reconciled with replica count.
Keep the rollback switch independent of the contact form. The system's useful fallback is a correctly routed request for help, even while delivery evidence arrives slowly.
References
- Google, Email sender guidelines: https://support.google.com/a/answer/81126
- Twilio, SMS character limits and segmentation: https://www.twilio.com/docs/glossary/what-sms-character-limit
- Resend documentation: https://resend.com/docs
- Amazon SES developer guide: https://docs.aws.amazon.com/ses/latest/dg/Welcome.html
Top comments (0)