Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Who Builds America’s Aircraft Carriers And Where Are They Made?

    8 Propeller Planes Powered By Diesel Engines

    This Cheap iPad Mini Alternative Might Be 2025’s Best Tablet (According To Reviews)

    Facebook X (Twitter) Instagram
    • Artificial Intelligence
    • Business Technology
    • Cryptocurrency
    • Gadgets
    • Gaming
    • Health
    • Software and Apps
    • Technology
    Facebook X (Twitter) Instagram Pinterest Vimeo
    Tech AI Verse
    • Home
    • Artificial Intelligence

      Blue-collar jobs are gaining popularity as AI threatens office work

      August 17, 2025

      Man who asked ChatGPT about cutting out salt from his diet was hospitalized with hallucinations

      August 15, 2025

      What happens when chatbots shape your reality? Concerns are growing online

      August 14, 2025

      Scientists want to prevent AI from going rogue by teaching it to be bad first

      August 8, 2025

      AI models may be accidentally (and secretly) learning each other’s bad behaviors

      July 30, 2025
    • Business

      Why Certified VMware Pros Are Driving the Future of IT

      August 24, 2025

      Murky Panda hackers exploit cloud trust to hack downstream customers

      August 23, 2025

      The rise of sovereign clouds: no data portability, no party

      August 20, 2025

      Israel is reportedly storing millions of Palestinian phone calls on Microsoft servers

      August 6, 2025

      AI site Perplexity uses “stealth tactics” to flout no-crawl edicts, Cloudflare says

      August 5, 2025
    • Crypto

      Former Indian Politician Convicted in Bitcoin Extortion Case

      August 30, 2025

      Top 3 Real World Asset (RWA) Altcoins to Watch in September

      August 30, 2025

      Ethereum Dip May Be Temporary with $1 Billion Whale Buys and Slower Profit Taking

      August 30, 2025

      Everything We Know So Far About the Bitcoin Thriller “Killing Satoshi”

      August 30, 2025

      Why HBAR’s Bearish Sentiment Might Be Its Trigger for a Price Rebound

      August 30, 2025
    • Technology

      Who Builds America’s Aircraft Carriers And Where Are They Made?

      August 30, 2025

      8 Propeller Planes Powered By Diesel Engines

      August 30, 2025

      This Cheap iPad Mini Alternative Might Be 2025’s Best Tablet (According To Reviews)

      August 30, 2025

      How Much Does Ryobi’s 4000W Inverter Generator Cost & How Long Will It Run?

      August 30, 2025

      Are Hart Batteries Compatible With DeWalt Tools?

      August 30, 2025
    • Others
      • Gadgets
      • Gaming
      • Health
      • Software and Apps
    Check BMI
    Tech AI Verse
    You are at:Home»Technology»Log by time, not by count
    Technology

    Log by time, not by count

    TechAiVerseBy TechAiVerseJuly 21, 2025No Comments2 Mins Read2 Views
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Share
    Facebook Twitter LinkedIn Pinterest WhatsApp Email

    BMI Calculator – Check your Body Mass Index for free!

    Log by time, not by count

    July 20, 2025

    “How to Log” is a surprisingly deep topic in software engineering with many different viewpoints, and they’re almost all valid in different situations. I’m going to argue that when processing lots of events, it’s best to log every X seconds, rather than every X messages. This is a simple concept, but I’ve never seen it written down before.

    Let’s quickly look at some pseudocode to understand what I mean.

    Count-based logging

    num_events_processed = 0
    
    while True:
        event = read_event_from_queue()
        process_event(event)
        num_events_processed += 1
    
        if num_events_processed % 1_000 == 0:
            module_logger.info("Processed 1000 events.")
    

    Time-based logging

    last_time_logged = time.time()
    num_events_processed_since_last_log = 0
    
    while True:
        event = read_event_from_queue()
        process_event(event)
        num_events_processed_since_last_log += 1
    
        current_time = time.time()
        if current_time - last_time_logged >= 1.0:
            module_logger.info(f"Processed {num_events_processed_since_last_log} events.")
            num_events_processed_since_last_log = 0
            last_time_logged = current_time
    

    Default to writing time based logging.

    Log rate should be consistent

    If you log too much:

    • Time spent logging is time you aren’t spending processing events. You slow your system down when it’s at peak load.
    • Lots of useless logs are costly to consume and retain.
    • Lots of useless logs slow down searching through the logs, reducing observability.

    And if you don’t log enough:

    • You might not know if your application is even running!
    • Low observability.

    The problem with logging every X messages is that there isn’t a good value for X. Your application might process millions of messages per second in production, but only ~5 each second when running locally for testing. You should emit logs at a constant rate in both these cases, and time-based logging provides that.

    BMI Calculator – Check your Body Mass Index for free!

    Share. Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Telegram Email
    Previous ArticleAgents built from alloys
    Next Article BBC plans to outsource and offshore thousands of tech roles
    TechAiVerse
    • Website

    Jonathan is a tech enthusiast and the mind behind Tech AI Verse. With a passion for artificial intelligence, consumer tech, and emerging innovations, he deliver clear, insightful content to keep readers informed. From cutting-edge gadgets to AI advancements and cryptocurrency trends, Jonathan breaks down complex topics to make technology accessible to all.

    Related Posts

    Who Builds America’s Aircraft Carriers And Where Are They Made?

    August 30, 2025

    8 Propeller Planes Powered By Diesel Engines

    August 30, 2025

    This Cheap iPad Mini Alternative Might Be 2025’s Best Tablet (According To Reviews)

    August 30, 2025
    Leave A Reply Cancel Reply

    Top Posts

    Ping, You’ve Got Whale: AI detection system alerts ships of whales in their path

    April 22, 2025168 Views

    6.7 Cummins Lifter Failure: What Years Are Affected (And Possible Fixes)

    April 14, 202548 Views

    New Akira ransomware decryptor cracks encryptions keys using GPUs

    March 16, 202530 Views

    Is Libby Compatible With Kobo E-Readers?

    March 31, 202528 Views
    Don't Miss
    Technology August 30, 2025

    Who Builds America’s Aircraft Carriers And Where Are They Made?

    Who Builds America’s Aircraft Carriers And Where Are They Made? Rawpixel.com/Shutterstock The U.S. military is…

    8 Propeller Planes Powered By Diesel Engines

    This Cheap iPad Mini Alternative Might Be 2025’s Best Tablet (According To Reviews)

    How Much Does Ryobi’s 4000W Inverter Generator Cost & How Long Will It Run?

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us
    About Us

    Welcome to Tech AI Verse, your go-to destination for everything technology! We bring you the latest news, trends, and insights from the ever-evolving world of tech. Our coverage spans across global technology industry updates, artificial intelligence advancements, machine learning ethics, and automation innovations. Stay connected with us as we explore the limitless possibilities of technology!

    Facebook X (Twitter) Pinterest YouTube WhatsApp
    Our Picks

    Who Builds America’s Aircraft Carriers And Where Are They Made?

    August 30, 20252 Views

    8 Propeller Planes Powered By Diesel Engines

    August 30, 20252 Views

    This Cheap iPad Mini Alternative Might Be 2025’s Best Tablet (According To Reviews)

    August 30, 20251 Views
    Most Popular

    Xiaomi 15 Ultra Officially Launched in China, Malaysia launch to follow after global event

    March 12, 20250 Views

    Apple thinks people won’t use MagSafe on iPhone 16e

    March 12, 20250 Views

    French Apex Legends voice cast refuses contracts over “unacceptable” AI clause

    March 12, 20250 Views
    © 2025 TechAiVerse. Designed by Divya Tech.
    • Home
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions

    Type above and press Enter to search. Press Esc to cancel.