awksedgreep1

awksedgreep1

Syslog server performance issue with appending log

Apologies if this has been asked before, but I couldn’t find a reference to this issue on the forum.

I’m writing a syslog server for a DOCSIS stack I’m working on and would love to have an efficient way to append a log. I’m currently using File.write! with the following options, which seem ideal for what I’m trying to accomplish: [:append, {:delayed_write, 1000, 10_000}] This needs to scale to tens of thousands of devices(cable modems) logging to it so performance is paramount.

It appears that the append does what has been requested, but when the log files get large(>500M) the File.write! seems to slow down drastically. It seems to be reading the entire file to find the end after every delayed write tries to write the file.

Two questions:
Can I append to a file any other way?

Is there something I’m missing in my current implementation, an option perhaps that allows me to hold the end of the log position and append from there?

'njoy,
Mark

Marked As Solved

awksedgreep1

awksedgreep1

Was able to double performance again and get more consistent results with the following. Going to mark this as a solution since I couldn’t get a combination of options to work with :raw.

{:ok, file} = File.open(@csv_file_path, [:append, :utf8, :delayed_write])

What was taking about 15 minutes(10m writes) is down to 2:45.

'njoy,
Mark

Also Liked

axelson

axelson

Scenic Core Team

If you haven’t already seen it you may also be interested in “raw” mode. It can greatly improve file performance although of course it comes with some tradeoffs.

awksedgreep1

awksedgreep1

Decided to read the source code and found this:

Warning: Every time this function is invoked, a file descriptor is opened
and a new process is spawned to write to the file. For this reason, if you are
doing multiple writes in a loop, opening the file via File.open/2 and using
the functions in IO to write to the file will yield much better performance
than calling this function multiple times.

That’s on File.write.

Going to refactor with file stream in state and writes via IO module and see if that improves the situation.

awksedgreep1

awksedgreep1

Performance is better after the refactor. I’ll try raw mode now and see if it improves further. I just timed the new IO.write and it took 4min 50sec to do 10m messages. Vast improvement, but I think it could be better. Thank you for the suggestion.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement