Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6650081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:51:02+00:00 2026-05-26T00:51:02+00:00

I have an application that needs to save a large number of this type

  • 0

I have an application that needs to save a large number of this type of class/information:

public struct PrimaryPacket
{
    public uint IPAddress;
    public ushort UDPPort;
    public ushort TCPPort;
    public uint RequestID;
    public byte Hop;
    public byte FreePrimaries;
    public byte FreeSecondaries;
    public ushort Length;
    public byte[] Data;
}

Currently I am using this for storing the items, with the key being the IPAddress and RequestID in a uint[] array:

ConcurrentDictionary<uint[], PrimaryPacket> Packets = new ConcurrentDictionary<uint[], PrimaryPacket>();

However, the extremely large amount of these I need to store is about 10,000 new items per second (saving them for up to one hour) and the memory usage becomes insane.

If I were to use a database for this would it be any more efficient (and less of a memory hog) ? And should I be looking at using mysql or something like mongodB?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:51:03+00:00Added an answer on May 26, 2026 at 12:51 am

    If you just want a log of all the data so that you can restore your state in the case of a restart, a simple flat file will work fine. Any system can keep up with writing 1MB/sec as long as you buffer the writes. If you’re going to be doing random access, though, it’s a different story.

    You mentioned that you’re going to have 10k inserts per second. Even without reads (writing only), it will take a lot of work and fairly expensive hardware to get that kind of bandwidth for random access.

    Since you are only going to be keeping an hour’s worth of data (36M records), it will probably be much cheaper and easier to just store the data in memory. Assuming it takes 100 bytes to store all the data for a record, you’ll only need an additional 4GB. Because it requires 4GB just to store the data, I’m going to assume you have a 64-bit machine.

    Your current implementation of ConcurrentDictionary<uint[], PrimaryPacket> has some problems, though.

    First of all, using a uint[] as a dictionary key is a bad idea because two different arrays with the same contents are not considered equal — you’ll never be able to look up anything in your dictionary! Since the key is 8 bytes, I would recommend a struct such as ulong, KeyValuePair<uint, uint>, or a custom one. I would not recommend a Tuple<uint, uint> because it will have something like 24 bytes of overhead.

    Second, it looks like you may be defining PrimaryPacket as a struct. For an object this large, you will likely find that you get better performance defining it as a class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little Cocoa Application that needs to save its settings. Is it
I have a c# WPF application that needs to save data when it closes.
I have an iPhone application that needs to save an image onto the database
We have an application that needs to know the path that it is executed
I have an application that needs to send a moderately high volume of messages
I have an application that needs to hit the ActiveDirectory to get user permission/roles
I have an application that needs to poll a webservice to see if the
we have an application that needs to send out various different types of template
I have an application that needs to work with a vendor-supplied API to do
I have an application that needs to check a website feed every second. Sometimes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.