Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I wonder what would be a more efficient way to partition Parquet data when storing it in S3.
In my cluster I currently have a folder data with a huge amount of Parquet files. I would like to change the way I save data in order to simplify the data retrieval.
I have two options. One option is to store Parquet files in the following folder path:
PARTITION_YEAR=2017/PARTITION_MONTH=07/PARTITION_DAY=12/my-parquet-files-go-here
or
PARTITION_DATE=20170712/my-parquet-files-go-here
Which of these two alternatives would be more recommended if I need to read a range of 7 days in Spark using spark.read.parquet?
Which alternative would be faster?
Since in both cases you are storing data with daily granularity, given the appropriate implementation at read time these two should be equivalent, but the former allows you to define better grained pruning based on your needs: you can easily get data for a whole year, a single month or a single day (or a combination of those) with well supported glob patterns.
I'd encourage you to use the former solution to be more flexible, as for your current use case the efficiency doesn't change significantly.
I would strongly advise against having many, many folders in your s3 store. Why? Spark uses S3 connectors which mimic directory trees through multiple HTTP requests: the deeper and wider the tree, the more inefficient this becomes, not least because AWS S3 throttles HTTP requests
The year/month/day naming scheme works well with hive & spark, but if you go into too much depth (by day, by hour) then you may experience worse performance than if you didn't.
The answer is quite simple... it depends on how you will query the data!
If you are querying purely on a range of days, then the second option is the easiest:
SELECT ...
FROM table
WHERE date BETWEEN ... AND ...
If you partition by month and day, you'd have to write a WHERE clause that uses both fields, which would be difficult if the desired 7-day range straddles two moths (eg 2018-05-27 to 2015-06-02):
SELECT ...
FROM table
WHERE (month = 5 and date BETWEEN 27 AND 31) OR
(month = 6 and date BETWEEN 1 AND 2)
This is the best way to make the partitions work, but is not very efficient for coding.
Thus, if you are using a WHERE on the date, then partition by date!
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
Problem:
Looking for best solution to store and make easily available big amount of weather data for the machine learning specialists team.
Initially I'm fetching data from cds.climate.copernicus.eu in netCDF or grib format. There will be some around 10-20Tb in grib or netCDF.
Requirements:
ML specialists can easily query data for given location (point, polygon) in given time range.
Results are returned in reasonable time.
Ideas:
Postgres. I thought that maybe pg would handle that amount of data. But the problem I encoutered with this is that loading data into postgres will take ages additionally it would take much more space than 10-20Tb (Because I planned to store that in row like format where you have two tables Point and WeatherMeasurement) Is it a good idea? Have anyone experience with this kind of data and pg?
Amazon Redshift. Would it be good approach to use this solution for weather data. How to load netCDf or grib into it? I have zero experience with could solutions like this.
Files. Just store data in the grib or netCDF files. I would write some simplified Python interface to fetch data from those files? But the questions is will the queries be fast enough? Have anyone experience with those?
For data this size that you want to sub-select quickly along multiple dimensions I'd lean toward Redshift. You will want to pay attention to how you want to query the data and establish the data model to provide the fastest access for the needed subsets. You may want to get some help setting this up initially as trial-and-error approach will take a while with this data size. Also Redshift isn't cheap at this scale so ask the budget questions too. This can be reduced if the database only needs to be up part of the time.
Files isn't a terrible idea as long as you can partition the data such that only a subset of files need to be accessed for any query. A partitioning strategy based on YEAR, MONTH, LAT-Decade, and LON-Decade might work - you'll need to understand what queries need to be performed and how fast (what's reasonable time?). This approach will be the least cost.
There is also a combo option - Redshift Spectrum. Redshift can utilize on database information AND in S3 stored data in the same queries. Again setting up the Redshift data model and S3 partitioning will be critical but this combo could give you attributes that will be valuable.
For any of these options you will want to convert to a more database friendly format like Parquet (or even CSV). This conversion process along with how to merge new data will need to be understood. There are lots of cloud tools to help with this processing.
Given the size of data you are working with I'll stress again that learning as you go will be time consuming. You will likely want to find experts in the tools you are working with (and at the data sizes you have) to get up quickly.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am working with Spark (pyspark) and MongoDB as a relational database.
We are running into some performance issues and the answers I found here were not directly related to Big Data.
We pull our entire mongoDB and then filter in Spark and when we apply some filters, some of the columns we don't filter are still present in the spark DataFrame(let me explain better this last case later).
My questions, besides a general understanding of the question's tittle:
Pull and filter, or filter and pull. If it's not a clear answer what are the parameters to start taking into account?
Let's say I have a Spark DataFrame with columns A,B,C and I filter only on C, it would be better (assuming I pulled everything) to drop then A and B?
Any links or readings regarding this are welcome.
1 - pull filtered data , it is more efficient to pull only the data you want. most database are optimize to do filter operation. the perfect case is when you can partition your data on your filtering columns (in your case columns C i guess)
2 - I am not sure but i think it's better to drop the colums you dont use, mainly to reduce the shuffle size if shuffle you have. and it also make your DataFrame more clear
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am working on a real time feed which gives me real time data.
The Number of records are up to 1 million per month and I need to provide reports based on these records.
I chose Mongodb as it is high performer in fetching records.
I am facing issue in managing that data because 12 million records.
Do I need to keep every data month wise?
Should I use different collections per month?
There are lot of select queries for Analytics Report and everything.
It depends on how you want to use the data, that's up to you to decide. There is nothing wrong with a lot of data, you just need to limit your heavy queries with the same logic as cache works (easier access, but less fresh). A common methods is:
You have a "raw data" table which contains your millions of records. This table is very large, but contains 'pure' data. You want to access this table as little as possible as it'll be slow.
The next table is less accurrate and sums information you need. In your case this could be a 'month_summery' which you create after a month ends. That way you still have the complete dataset, but also a small table with relevent info (e.g. num lines, sumOfX, averageOfY, etc). Your heavy query is now once per month and you can base your stats of this.
If you need data say per week, you'd make a 'week_summery' table. Or if you need stats per day, you make it per day, 365 entries per year is still a whole lot less than millions.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have a data-set that consist of 1500 columns and 6500 rows and I am trying to figure out what the best way is to shape the data for web based user interactive visualizations.
What I am trying to do is make the data more interactive and create an admin console that allows anyone to filter the data visually.
Front-end could potentially be based on Crossfilter, D3 and DC.js and give the user basically end-less filtering possibilities(date, value, country. In addition there will be some pre defined views like top and bottom 10 values.
I have seen and tested some great examples like this one, but after testing it did not really fit for the large amount of columns I had and it was based on a full JSON dump from the MongoDB. This amounted in very long loading times and loss of full interactivity with the data.
So in the end my question is what is the best approach (starting with normalization) in getting the data shaped in the right way so it can be manipulated from a front-end. Changing the amount of columns is a priority.
A quick look at the piece of data that you shared suggests that the dataset is highly denormalized. To allow for querying and visualization from a database backend I would suggest normalizing. This is no small bit software work but in the end you will have relational data which is much easier to deal with.
It's hard to guess where you would start but from the bit of data you showed there would be a country table, an event table of some sort and probably some tables of enumerated values.
In any case you will have a hard time finding a db engine that a lows that many columns. The row count is not a problem. I think in the end you will want a db with dozens of tables.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I was thinking of using a database like mongodb or ravendb to store a lot of stock tick data and wanted to know if this would be viable compared to a standard relational such as Sql Server.
The data would not really be relational and would be a couple of huge tables. I was also thinking that I could sum/min/max rows of data by minute/hour/day/week/month etc for even faster calculations.
Example data:
500 symbols * 60 min * 60sec * 300 days... (per record we store: date, open, high,low,close, volume, openint - all decimal/float)
So what do you guys think?
Since when this question was asked in 2010, several database engines were released or have developed features that specifically handle time series such as stock tick data:
InfluxDB - see my other answer
Cassandra
With MongoDB or other document-oriented databases, if you target performance, the advices is to contort your schema to organize ticks in an object keyed by seconds (or an object of minutes, each minute being another object with 60 seconds). With a specialized time series database, you can query data simply with
SELECT open, close FROM market_data
WHERE symbol = 'AAPL' AND time > '2016-09-14' AND time < '2016-09-21'
I was also thinking that I could sum/min/max rows of data by minute/hour/day/week/month etc for even faster calculations.
With InfluxDB, this is very straightforward. Here's how to get the daily minimums and maximums:
SELECT MIN("close"), MAX("close") FROM "market_data" WHERE WHERE symbol = 'AAPL'
GROUP BY time(1d)
You can group by time intervals which can be in microseconds (u), seconds (s), minutes (m), hours (h), days (d) or weeks (w).
TL;DR
Time-series databases are better choices than document-oriented databases for storing and querying large amounts of stock tick data.
The answer here will depend on scope.
MongoDB is great way to get the data "in" and it's really fast at querying individual pieces. It's also nice as it is built to scale horizontally.
However, what you'll have to remember is that all of your significant "queries" are actually going to result from "batch job output".
As an example, Gilt Groupe has created a system called Hummingbird that they use for real-time analytics on their web site. Presentation here. They're basically dynamically rendering pages based on collected performance data in tight intervals (15 minutes).
In their case, they have a simple cycle: post data to mongo -> run map-reduce -> push data to webs for real-time optimization -> rinse / repeat.
This is honestly pretty close to what you probably want to do. However, there are some limitations here:
Map-reduce is new to many people. If you're familiar with SQL, you'll have to accept the learning curve of Map-reduce.
If you're pumping in lots of data, your map-reduces are going to be slower on those boxes. You'll probably want to look at slaving / replica pairs if response times are a big deal.
On the other hand, you'll run into different variants of these problems with SQL.
Of course there are some benefits here:
Horizontal scalability. If you have lots of boxes then you can shard them and get somewhat linear performance increases on Map/Reduce jobs (that's how they work). Building such a "cluster" with SQL databases is lot more costly and expensive.
Really fast speed and as with point #1, you get the ability to add RAM horizontally to keep up the speed.
As mentioned by others though, you're going to lose access to ETL and other common analysis tools. You'll definitely be on the hook to write a lot of your own analysis tools.
Here's my reservation with the idea - and I'm going to openly acknowledge that my working knowledge of document databases is weak. I’m assuming you want all of this data stored so that you can perform some aggregation or trend-based analysis on it.
If you use a document based db to act as your source, the loading and manipulation of each row of data (CRUD operations) is very simple. Very efficient, very straight forward, basically lovely.
What sucks is that there are very few, if any, options to extract this data and cram it into a structure more suitable for statistical analysis e.g. columnar database or cube. If you load it into a basic relational database, there are a host of tools, both commercial and open source such as pentaho that will accommodate the ETL and analysis very nicely.
Ultimately though, what you want to keep in mind is that every financial firm in the world has a stock analysis/ auto-trader application; they just caused a major U.S. stock market tumble and they are not toys. :)
A simple datastore such as a key-value or document database is also beneficial in cases where performing analytics reasonably exceeds a single system's capacity. (Or it will require an exceptionally large machine to handle the load.) In these cases, it makes sense to use a simple store since the analytics require batch processing anyway. I would personally look at finding a horizontally scaling processing method to coming up with the unit/time analytics required.
I would investigate using something built on Hadoop for parallel processing. Either use the framework natively in Java/C++ or some higher level abstraction: Pig, Wukong, binary executables through the streaming interface, etc. Amazon offers reasonably cheap processing time and storage if that route is of interest. (I have no personal experience but many do and depend on it for their businesses.)