Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
Gampaha
Thenya Mishel
menuka2000
Updated:
Wednesday at 10:48 PM
Handmade Character Soft Toy Bluey Bingo
anil1961
Updated:
Aug 3, 2026
Colombo
Dahua POE Switch 8 Ports (DH-PFS3010-8ET-65)
hashaz2012
Updated:
Aug 3, 2026
Ad icon
Singapore V2Ray VPN for Tunneling
hu KANNA
Updated:
Jul 31, 2026
Dating Website & Online Chat Room
hotvideo
Updated:
Jul 30, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Software Development
Java ඉවරයි ගුපියනේ... ඉස්සරහට Go තමයි... 🦾😎
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="thota_langa_sirikkiya" data-source="post: 31216460" data-attributes="member: 561404"><p>Just a response from Gemini</p><h2>1. The Virtual Waiting Room (VWR)</h2><p>To keep costs low, you must stop the "Million-User Surge" before it reaches your actual servers.</p><p></p><ul> <li data-xf-list-type="ul"><strong>Implementation:</strong> Use a <strong>Cookie-based Token</strong> system. When a user hits your URL, a lightweight edge worker (like Cloudflare Workers or an Nginx script) checks for a "Passed_Queue" cookie.</li> <li data-xf-list-type="ul"><strong>The Logic:</strong> If they don't have it, they are redirected to a static waiting page. This page is served from a CDN (Content Delivery Network), meaning it costs you almost nothing.</li> <li data-xf-list-type="ul"><strong>The "Trickle":</strong> Your backend tells the VWR: <em>"I can handle 2,000 new checkouts per minute."</em> The VWR then releases exactly that many tokens.</li> <li data-xf-list-type="ul"><strong>Budget Benefit:</strong> You only pay for a server capable of handling 2,000 active users, even though 1,000,000 are "waiting."</li> </ul><hr /><h2>2. Inventory Management via Redis Lua</h2><p>Standard SQL UPDATE tickets SET status = 'booked' WHERE id = 1 will fail under high concurrency due to <strong>row-locking</strong>. Instead, use Redis.</p><p></p><ul> <li data-xf-list-type="ul"><strong>Atomic Decrement:</strong> Redis is single-threaded, making it perfect for counting. You can use a <strong>Lua Script</strong> to ensure that "Check availability" and "Deduct ticket" happen in one atomic step.</li> <li data-xf-list-type="ul"><strong>Sample Logic:</strong><br /> Lua<br /> <br /> -- KEYS[1] = event_id, ARGV[1] = quantity_requested<br /> local count = tonumber(redis.call('get', KEYS[1]))<br /> if count >= tonumber(ARGV[1]) then<br /> redis.call('decrby', KEYS[1], ARGV[1])<br /> return 1 -- Success<br /> else<br /> return 0 -- Sold out<br /> end<br /> <br /> </li> <li data-xf-list-type="ul"><strong>Why Go?</strong> Use <strong>Golang</strong> for this API. Go’s "Goroutines" are extremely lightweight. A $20/month server running Go can handle 10x the traffic of a similarly priced Node.js or Python server because Go manages memory much more efficiently.</li> </ul><hr /><h2>3. Asynchronous Ordering (The Buffer)</h2><p>Once Redis says "Success," do <strong>not</strong> write to the SQL database yet. That is the slowest part of any system.</p><p></p><ul> <li data-xf-list-type="ul"><strong>Message Queue (MQ):</strong> Push the booking details into a queue (like <strong>NATS</strong>—which is faster/cheaper than RabbitMQ).</li> <li data-xf-list-type="ul"><strong>Worker Pattern:</strong> A "Worker" service reads from the queue at its own pace and writes to the <strong>PostgreSQL</strong> database.</li> <li data-xf-list-type="ul"><strong>Order Preservation:</strong> NATS and RabbitMQ can be configured for <strong>FIFO (First-In, First-Out)</strong>. Because you only push to the queue <em>after</em> the Redis Lua script confirms availability, the order is naturally preserved based on who "won" the Redis race.</li> </ul><hr /><h2>4. Payment & Idempotency</h2><p>Payment is the most dangerous part because you can't "undo" a credit card charge easily.</p><p></p><ul> <li data-xf-list-type="ul"><strong>The 10-Minute Hold:</strong> When Redis deducts a ticket, set a "Pending" key with a TTL (Time-to-Live) of 10 minutes.</li> <li data-xf-list-type="ul"><strong>Idempotency Keys:</strong> Every request must have a unique request_id. If a user clicks "Pay" twice because their internet is slow, your backend checks the request_id in Redis. If it exists, it ignores the second click. This prevents double-charging.</li> <li data-xf-list-type="ul"><strong>Webhooks:</strong> Use a <strong>Serverless Function</strong> (like AWS Lambda) to listen for the payment gateway's "Success" signal. This scales automatically and you only pay per "Success" message, saving money during the 99% of the year when there are no events.</li> </ul><hr /><h2>5. Summary of Costs vs. Performance</h2> <table style='width: 100%'><tr><td><strong>Layer</strong></td><td><strong>Strategy</strong></td><td><strong>Budget Status</strong></td></tr><tr><td><strong>Front Door</strong></td><td>CDN + Static Waiting Room</td><td><strong>Very Cheap</strong> (Pay per GB)</td></tr><tr><td><strong>Application</strong></td><td>Go (Golang) Microservices</td><td><strong>Highly Efficient</strong> (Small servers)</td></tr><tr><td><strong>Inventory</strong></td><td>Redis (In-memory)</td><td><strong>Predictable</strong> (One fixed-size instance)</td></tr><tr><td><strong>Database</strong></td><td>PostgreSQL (RDS/Cloud)</td><td><strong>Optimized</strong> (Only handles confirmed sales)</td></tr></table><h3>Pro-Architect Tip:</h3><p><strong>Warm the Cache.</strong> 10 minutes before the event starts, "pre-load" all ticket counts into Redis. Never let your million users trigger a "SELECT COUNT(*)" on your SQL database during the rush.</p><p></p><p><img src="https://i.imgur.com/fRE7yzW.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p></blockquote><p></p>
[QUOTE="thota_langa_sirikkiya, post: 31216460, member: 561404"] Just a response from Gemini [HEADING=1]1. The Virtual Waiting Room (VWR)[/HEADING] To keep costs low, you must stop the "Million-User Surge" before it reaches your actual servers. [LIST] [*][B]Implementation:[/B] Use a [B]Cookie-based Token[/B] system. When a user hits your URL, a lightweight edge worker (like Cloudflare Workers or an Nginx script) checks for a "Passed_Queue" cookie. [*][B]The Logic:[/B] If they don't have it, they are redirected to a static waiting page. This page is served from a CDN (Content Delivery Network), meaning it costs you almost nothing. [*][B]The "Trickle":[/B] Your backend tells the VWR: [I]"I can handle 2,000 new checkouts per minute."[/I] The VWR then releases exactly that many tokens. [*][B]Budget Benefit:[/B] You only pay for a server capable of handling 2,000 active users, even though 1,000,000 are "waiting." [/LIST] [HR][/HR] [HEADING=1]2. Inventory Management via Redis Lua[/HEADING] Standard SQL UPDATE tickets SET status = 'booked' WHERE id = 1 will fail under high concurrency due to [B]row-locking[/B]. Instead, use Redis. [LIST] [*][B]Atomic Decrement:[/B] Redis is single-threaded, making it perfect for counting. You can use a [B]Lua Script[/B] to ensure that "Check availability" and "Deduct ticket" happen in one atomic step. [*][B]Sample Logic:[/B] Lua -- KEYS[1] = event_id, ARGV[1] = quantity_requested local count = tonumber(redis.call('get', KEYS[1])) if count >= tonumber(ARGV[1]) then redis.call('decrby', KEYS[1], ARGV[1]) return 1 -- Success else return 0 -- Sold out end [*][B]Why Go?[/B] Use [B]Golang[/B] for this API. Go’s "Goroutines" are extremely lightweight. A $20/month server running Go can handle 10x the traffic of a similarly priced Node.js or Python server because Go manages memory much more efficiently. [/LIST] [HR][/HR] [HEADING=1]3. Asynchronous Ordering (The Buffer)[/HEADING] Once Redis says "Success," do [B]not[/B] write to the SQL database yet. That is the slowest part of any system. [LIST] [*][B]Message Queue (MQ):[/B] Push the booking details into a queue (like [B]NATS[/B]—which is faster/cheaper than RabbitMQ). [*][B]Worker Pattern:[/B] A "Worker" service reads from the queue at its own pace and writes to the [B]PostgreSQL[/B] database. [*][B]Order Preservation:[/B] NATS and RabbitMQ can be configured for [B]FIFO (First-In, First-Out)[/B]. Because you only push to the queue [I]after[/I] the Redis Lua script confirms availability, the order is naturally preserved based on who "won" the Redis race. [/LIST] [HR][/HR] [HEADING=1]4. Payment & Idempotency[/HEADING] Payment is the most dangerous part because you can't "undo" a credit card charge easily. [LIST] [*][B]The 10-Minute Hold:[/B] When Redis deducts a ticket, set a "Pending" key with a TTL (Time-to-Live) of 10 minutes. [*][B]Idempotency Keys:[/B] Every request must have a unique request_id. If a user clicks "Pay" twice because their internet is slow, your backend checks the request_id in Redis. If it exists, it ignores the second click. This prevents double-charging. [*][B]Webhooks:[/B] Use a [B]Serverless Function[/B] (like AWS Lambda) to listen for the payment gateway's "Success" signal. This scales automatically and you only pay per "Success" message, saving money during the 99% of the year when there are no events. [/LIST] [HR][/HR] [HEADING=1]5. Summary of Costs vs. Performance[/HEADING] [TABLE] [TR] [TD][B]Layer[/B][/TD] [TD][B]Strategy[/B][/TD] [TD][B]Budget Status[/B][/TD] [/TR] [TR] [TD][B]Front Door[/B][/TD] [TD]CDN + Static Waiting Room[/TD] [TD][B]Very Cheap[/B] (Pay per GB)[/TD] [/TR] [TR] [TD][B]Application[/B][/TD] [TD]Go (Golang) Microservices[/TD] [TD][B]Highly Efficient[/B] (Small servers)[/TD] [/TR] [TR] [TD][B]Inventory[/B][/TD] [TD]Redis (In-memory)[/TD] [TD][B]Predictable[/B] (One fixed-size instance)[/TD] [/TR] [TR] [TD][B]Database[/B][/TD] [TD]PostgreSQL (RDS/Cloud)[/TD] [TD][B]Optimized[/B] (Only handles confirmed sales)[/TD] [/TR] [/TABLE] [HEADING=2]Pro-Architect Tip:[/HEADING] [B]Warm the Cache.[/B] 10 minutes before the event starts, "pre-load" all ticket counts into Redis. Never let your million users trigger a "SELECT COUNT(*)" on your SQL database during the rush. [img]https://i.imgur.com/fRE7yzW.png[/img] [/QUOTE]
Insert quotes…
Verification
Hath warak paha keeyada? (hatha wadikireema paha)
Post reply
Top
Bottom