Flask 6-Hour Restart 4 Days Stable + Cloudflare China IP Block: W11 Review
Same day I also did: added baccai.com to Cloudflare and blocked China IP. The two layers work completely independently, complementing each other: even if CF goes down schtasks still keeps Flask alive, even if bat gets cleaned out schtasks 6-hour forced restart can recover.
This article is W10 review + Cloudflare deployment summary, using 4 days of real data + monitoring logs to answer "is 6-hour restart too frequent" and "does CF block China affect SEO".
1. 4 Days 16 Auto Restarts, Zero Failures
The Sept 23 deployment was: bat loop instant pull on death + schtasks 6-hour forced taskkill. Two layers working independently.
4-day real data:
| Date | schtasks restarts | Avg downtime (s) | User complaints |
|---|---|---|---|
| Sept 23 (deployment day) | 4 | 22s | 0 |
| Sept 24 | 4 | 18s | 0 |
| Sept 25 | 4 | 17s | 0 |
| Sept 26 | 4 | 19s | 0 |
| Sept 27 (today) | 0 (not yet 6h) | - | 0 |
| Total | 16 restarts | avg 19s | 0 |
2. Is 6-Hour Restart Actually Too Frequent?
This was the biggest user concern after W10. I tracked real request time distribution over 4 days:
Sept 23-26 time distribution (from IIS log analysis):
00:00 - 06:00 11% requests (late night, overseas Chinese)
06:00 - 12:00 21% requests (Europe morning)
12:00 - 18:00 33% requests (Asia afternoon + US morning, peak)
18:00 - 24:00 35% requests (Asia evening, another peak)
schtasks restart times: 00:30 / 06:30 / 12:30 / 18:30
(intentionally pick low-traffic moments, avoid peaks)
Key insight: schtasks first trigger is the next 6-hour cycle after install. I deployed Sept 23 13:18, expected first restart Sept 23 19:18. Actual log shows 19:23, 5-minute offset (Windows scheduler lag).
User collision probability:
Assume 10-min session, 1 access/day = 10 min/day = 600s
Downtime window: 19s
Collision prob: 600 / 86400 × 19 / 600 = 0.022%
0.022% chance user hits window, 99.978% no impact.
4 days 0 complaints, matches math.
3. Cloudflare Blocking China IP (Sept 27 Added)
During HCU recovery, I made a critical decision: proactively block China IP. 3 reasons:
- HCU risk isolation: Even with current quality content, lots of China IP access triggers SpamBrain's "low quality content farm" signal
- Server load reduction: China IPs crawl 5000+ useless pages per day (SEO tools / scrapers), after block traffic dropped from 8GB/day to 1.2GB/day
- SEO focus on Google / Bing: Baidu strategically abandoned (Baidu SEO rules are completely different, terrible ROI)
CF Deployment Timeline (Sept 27)
NS switch needs 24-48 hours to fully propagate. Before that, some mainland users hit old GoDaddy DNS and reach IIS directly, bypassing WAF.
Why Not web.config Native IP Restriction?
IIS native IP restriction (ipSecurity) has 3 big issues:
| Feature | IIS ipSecurity | Cloudflare WAF |
|---|---|---|
| China IP maintenance | Manual 1000+ entries | CF auto |
| Maintenance cost | Monthly APNIC update | Zero |
| SEO impact | Depends on accuracy | 0 (Google/Bing not in CN) |
| DDoS protection | None | CF edge absorbs |
| Config complexity | Edit web.config + restart IIS | CF dashboard 1 minute |
Conclusion: CF is free web.config + DDoS protection + auto-maintenance, why not.
4. SEO Impact Tested (GSC Indexed)
Before Sept 27 CF deployment, GSC indexed = 21. Sept 27 deployment day + 1 day after:
| Date | GSC indexed | Change | Reason |
|---|---|---|---|
| Sept 23 (W10 post) | 21 | baseline | Slow recovery from 6/30 spam |
| Sept 24-26 | 21 | +0 | Googlebot in US, unaffected |
| Sept 27 (CF deployed) | 22 | +1 | W11 article posted, 1 new URL indexed |
| Test conclusion | CF blocking China IP has 0 impact on GSC indexed, Googlebot in US crawls normally | ||
5. Unexpected: Traffic Plunged
After CF WAF blocked China IP, server traffic dropped from 8GB/day to 1.2GB/day. Double effect of CF edge cache + WAF.
Sept 22 (pre-CF): 8.3 GB/day / 54000 requests / 8500 unique IPs
Sept 27 (post-CF): 1.2 GB/day / 12000 requests / 2200 unique IPs
Saved: 86% traffic / 78% requests / 74% IPs
Reasons: CF caches static files (CSS/JS/images),
China IPs blocked after WAF,
Some SEO crawlers auto-blocked by CF Bot Fight Mode
6. Current baccai.com Complete Guardian Chain
Sept 27 current baccai.com guardian stack:
| Layer | Mechanism | Function | Failure cost |
|---|---|---|---|
| 1. CF edge | DNS proxy + CDN cache + WAF | Acceleration + block + anti-DDoS | Degrades to direct, still works |
| 2. CF WAF | Country:CN Block | Block China IP | Mainland users can access (bypass) |
| 3. CF SSL | Full (Strict) | Verify ZeroSSL cert at origin | Degrades to Flexible (warning) |
| 4. schtasks 6h | taskkill python.exe /T | Force restart Flask | Next 6h to restart |
| 5. bat loop | Dead → instant pull + cd workdir | Process-level guardian | Process dead 5s before pull |
| 6. schtasks ONSTART | Boot 30s later run bat | Server reboot auto-recovery | Manual start needed |
Any layer fails, the other 5 fallback. This is the W10 "3-layer guardian" W11 upgrade: now 6 layers.
7. 3 Pitfalls (W11 Lessons)
Pitfall 1: WAF Rule Not Enabled
I filled out WAF rule but forgot to switch to "Active" (default "Disabled"). Result: rule didn't work, China could still access. Fix: re-enter WAF → enable → Deploy.
Pitfall 2: SSL Full (Strict) Not Verified
Cloudflare SSL mode Full (Strict) verifies origin cert (IIS). If IIS cert expired or path wrong, entire site 526 "Invalid SSL Certificate". Fix: confirm ZeroSSL cert not expired before switching.
Pitfall 3: NS Switch Not Instant
I assumed adding domain to CF + changing NS means China blocked instantly. Wrong, NS takes 24-48 hours. During that window, some China users hit GoDaddy DNS directly to IIS, completely bypassing CF WAF. Fix: wait 2 days patiently, don't repeatedly change CF config (extends propagation).
8. Next Steps (W12-W14 Preview)
- W12 (expected Oct 2): Zero-downtime rolling restart — Nginx + waitress multi-worker
- W13 (expected Oct 9): GSC indexed 21 → ? September complete data review
- W14 (expected Oct 16): baccai.com first quarterly SEO report — indexed, ranking, traffic
HCU recovery 3-6 month cycle at halfway point (Aug 22 first PGC article, now Sept 27 = 36 days, about 30% progress). By W14, indexed should reach 30-40, 5-10 keywords in top 50.