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 2 years ago.
Improve this question
I am working on a flutter project that gets data from my .net core web API. it works fine but every time I load my screen or switch between tabs in the app it gets data(content and pictures) from my API, although I estimate that my data may be usually updating once or twice a week. I want to know what is the best performance solution for this situation.
I will be happy if I know the opinion or experience of others in this regard.
thank you.
it works fine but every time I load my screen or switch between tabs
in the app it gets data(content and pictures) from my API, although I
estimate that my data may be usually updating once or twice a week. I
want to know what is the best performance solution for this situation.
Try to use F12 developer tools Performance panel to check which part of website need to improve the performance. Then, based on the result to do something.
Since the data are some content and pictures, you could consider using the following tips to improve the website performance:
Avoid synchronous and use asynchronous
Try to avoid synchronous calling when developing ASP.NET Core 3.0 applications. Synchronous calling blocks the next execution until the current execution is completed. While fetching data from an API or performing operations like I/O operations or independent calling, execute the call in an asynchronous manner. Avoid using Task.Wait and Task.Result, and try to use await.
Optimize data access
Most applications are totally dependent on a database. They have to fetch data from the database, process the data, and then display it. If it is time-consuming, then the application will take much more time to load.
Recommendations:
Call all data access APIs asynchronously.
Don’t try to get data that is not required in advance.
Try to use no-tracking queries in Entity Framework Core when accessing data for read-only purposes.
Use filter and aggregate LINQ queries (with .Where, .Select, or .Sum statements), so filtering can be performed by the database.
Use caching technology
Increase the performance of an application by reducing the number of requests to the server. Avoid calling the server every time and cache the data instead. Store the response for the future, and use it the next time you make a call for the same response.
Reference: Response caching in ASP.NET Core and use Response Caching Middleware.
Reduce HTTP requests and use response compression
Client-side improvements
Client-side optimization is one important aspect of improving performance, consider the following tips:
Bundle and minify static assets in ASP.NET Core
Use thumbnail images.
Reference: ASP.NET Core Performance Best Practices
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Good afternoon.
I'm testing my company's streaming service, which works like twitch.
The task is as follows:
Log in to your account and simulate viewing the stream ( and chat)
I was thinking of writing code in selenium. But as far as I understand, in this case you will have to use your own driver for each thread. I'm afraid it will take up too much memory.
Now the question.
It's true? Is there a way to avoid this?
What methods would you recommend to solve this problem?
I just came up with the idea to try not drawing videos to save resources. But there is one caveat here, so that the streaming service doesn't think I'm a bot.
In other words, I have to constantly get it, but not draw it.
This won't work with selenium.
The question is as follows: is it possible
to send login data to the form and "view" the stream programmatically in Java?
Which libraries should I use?
Can you recommend the necessary libraries with links to the functionality I need?
You can use a service for cloud-hosted testing for this, you will not have to care about the testing infrastructure then. Some services allow you to use Selenium in the test scripts, so test creation will be similar to a local testing experience.
Here is a link to a service that will allow you to achieve what you need and you can run some tests for free there.
Also here is a step-by-step guide to create and set your test.
The easiest way to achieve this would be to use Selenium Grid with TestNg.
As long as you need to validate the front end, selenium is the tool, if not 100%, you can simple test using API calls:
Log in via API calls
Perform a get on desired page and use a html parser to make some validations regarding the front end call
API calls to check the chat
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 5 years ago.
Improve this question
I've already run several times into the issue of creating a desktop client app for working with some server, and every time I ended with ugly code, which becomes just impossible to support after couple of releases.
I have highlighted the following key points:
All operations must be asynchronous, without any dummy windows for relative fast operations (i.e. less than 30 seconds)
App has to periodically connect with the server and check, for example, user account
All heavy operations must be cancelable
But, most important, all of this must be "naturally" in code, without creating unnecessary difficulties (singletons, hacks, etc)... only really needed code with minimal overhead.
How would you design such kind of app? What pattern would you use? What open source project with good architecture you can recommend?
This seems a little too broad, but instead of flagging I'll try and give an answer as I find the question interesting. I invite you to add more details if they come to mind.
Even though your design concerns the design of the application, there are a number of languages, patterns and technologies that would suit your requirements.
Keeping it general,
If your want your operations to be asynchronous, you are going to
need multiple threads. Their implementation and use may vary
depending on the language that you are using, but the concept behind
is the same. So, just spawn a thread every time you need an
asynchronous task, and implement a way to be noticed when the task is
done (with or without errors). This can be done in a number of ways,
since you asked for pattern I suggest you have a look at
observer.
The second requirement is not completely clear to me, I assume you
want to periodically check that the client's data is aligned with the
server's, and maybe perform security checks ("Are session and
authentication credentials still valid?"). The first solution is to
actually ask the server every n seconds, again using another
thread. This kind of polling might not be the best option though: how
do you factor in the possibility of connectivity issues? Even if your
client cannot operate without a working connection to the server, it
might bother the user to be disconnected and lose his work just
because his Wi-Fi router rebooted. I would suggest you perform
alignment checks at I/O, perhaps distinguishing between critical and
non-critical ones. For example, if you decide the user's profile
has to be aligned, then you would retrieve updated data from the server upon viewing it. On the other hand, if your app offers the
user a list of cooking recipes and you don't care about him not
viewing the one that has been inserted on the server 10 minutes in
the past, you could simply cache these items and refresh them in a
background thread every minute, without even noticing the user in
case the update fails. Last but not least, if you are also
concerned with concurrent modifications of data, again based on your
requirements you can decide to implement locks on data being edited,
to performs checks on save operations to see if the data has
changed in the meanwhile, or to simply let the user overwrite the
data on the server no matter what. All in all, hoping I interpreted
your question correctly, this requirement is nontrivial and has to be
adjusted to your particular use case.
Assuming the data is eventually saved on some sort of database on
the server, one answer are transactions, which allow you to
treat even complex sequences of operations as "all or nothing",
atomic instructions. You might implement your own system to have the
same result, but I don't really see the point of not using this
powerful instrument when possible. Keep in mind one thing: I'm
assuming "cancelable" means "cancelable before some point in time,
and not after" (a sort of "undo"). If you're looking for complete
revertability of any operation of data, the requirement becomes far
more complex, and in general not possible to guarantee.
I believed I already answered in a way that helps you minimize "hacks" in code where possible. To recap:
You are going to need threads, and the observer pattern can help you
keep the code clean.
Again, you can use threads, or focus on check on I/O operations. In
the second case, you might consider an application layer
specifically for client-server synchronization, embed it in one or
more classes, and perform all your checks there. Have a look at the
proxy pattern.
Use transactions to revert operations, and issue a COMMIT only
when you are sure that the operation is confirmed, a ROLLBACK in
every other case. Encapsule this logic in your server's code so that
the client is not aware of the actual transaction system being used,
and your code should be quite clean.
Please comment if my answer is not satisfying or clear.
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 8 years ago.
Improve this question
I'm not going to make a big long rattle on this question about what I've tested and number crunching. I'm more interested in actual up-to-date practice performances.
I've read tons of articles already and some of them are pretty skeptical or either very pro to one library. I'm currently testing a bit with gorp, yet I have no clue how to compare the performances of such a library towards others.
I know gorp is an extra layer that tries to add ORM to the basic SQL driver/implementation, but seeing Go's extremely clear code and being it very close to the bone on everything it does. It's not like with PHP/Python/JAVA what I'm used too, where you have to navigate through endless layers of complexity to actually see what a package does in its essence.
So my question is if anyone can share (benchmarks are always welcome :) ) their experience and knowledge on this subject.
I don't think a NoSQL-type solution is an option for my projects. All my projects always strongly depend on business logic and intertwined relationships. I also wonder if Postgres will be a win over MySQL. With Django (Python) I noticed significant performance gain using Postgres, but I never found prove on that matter if it was due to the Postgres core implementation or just Django's way of using the wrapper.
Small update
After rereading the question I noticed I kind of missed the actual goal of it. I'm actually looking for the most suitable SQL solution that will least slow down Golang itself. I know the SQL runs concurrent, but also concerning heavy traffic when running it as a web service. I won't be really bothered to drop the ORM part again if that will get me major gain on performance.
If you need to use an ORM sqlx or gorp are good Go options. Personally, I am a bit old school and I would rather for a given type Foo, I would rather write a FooDB struct that implements a FooDS interface. Everything in your app just uses FooDS. (DB = database, DS = datastore)
Your FooDB implementation could be using any number of underlying technologies MongoDB, LevelDB, SQL, etc and it can change as your app changes and this change is transparent to the rest of your app (since the rest of your app uses FooDS).
I would default to using database/sql (Prepared statements, etc) and the most mature Go SQL driver is Julien Schmidt's MySQL driver: https://github.com/go-sql-driver/mysql
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How to serialize the ViewModel ($scope) in AngularJS? I'm planning to store the serialized value to a ASP.NET server-side div to persists across postbacks.
$scope is an object created by AngularJS to interact with the markup. It can contain methods that can be referenced from html. You can create a simple JavaScript object for storing and transferring data and keep it in your scope.
$scope.model = { name : 'my model' };
Not sure if you should serialize the whole $scope (actually, you shouldn't - it's a complex object. You should only care about persisting your own data).
Use:
angular.toJson($scope.YourData);
obviously, there's a method-companion fromJson: http://docs-angularjs-org-dev.appspot.com/api/angular.fromJson
I am not sure about how your ASP.Net application is structured, but here are some of my inputs.
If you plan to do postbacks with ASP.Net I would suggest you to rethink you client side framework. AngularJS and many such similar frameworks are not meant for working with postback model. Typically what happens when you use frameworks like AngularJS
The server based on the request, sends HTML content (initial view) to client browser
The browser renders the view.
The client side Javascript frameworks kick in provide the necessary functionality
From this point onwards there is no post back, most of the functionality is achieved using AJAX requests, which does not cause a browser refresh.
If a navigate is performed from one page to another the process described above is repeated again.
As you can see postbacks are not natural to this setup, and any effort to bolt these two model together would produce less than optimum results.
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 3 years ago.
Improve this question
I'm using web based database for which I need to add spreadsheet capabilities to its front end. I was thinking that I could use Google Docs Spreadsheets. Their Google App Script seems to have the functionally that I need. In particular I can use the URLFetch service combined with onEdit events to keep the spreadsheet and DB in sync -- AJAX style. It also allows me a lot of flexibility in constructing, saving, and sharing the spreadsheets
However some things about Google App Script gave me pause. It runs server-side so it's difficult to debug locally. It doesn't have any sort of debugger with breakpoints or stepping. It can't import external modules or libraries. No JSLint. Without these I started getting that "Uh, oh, this is going to hurt" feeling.
So I'm wondering if there's a better way to bolt on browser accessible spreadsheet functionality to an existing web based database? Or are there best practices for getting the most out of Google App Script?
EDIT:
These are the potential solutions in order of what would be best for my application:
Browser based JavaScript spreadsheet engine. (May not exist.)
Python spreadsheet engine module that I can install on Google App Engine. (I haven't seen this either.)
An more robust and AJAXian approach to Google Spreadsheets. (See original question.)
Open source spreadsheet engines that I can install on EC2. (These seem to exist -- possibly SocialCalc, or Simple Spreadsheet. Recommendations?)
We use spreadsheet functionality on a web page, but rather than scripting all the features of a spreadsheet, we use a calculation engine which gives us the programmatic heart of spreadsheet functionality. A calculation engine knows how to calculate hundreds of types of formulas, handle dependencies (and the order between dependencies), cell formatting etc.
In my particular case, we use SpreadsheetGear - http://www.spreadsheetgear.com/products/spreadsheetgear.net.aspx
We create a HTML representation of a spreadsheet with cell navigation and various other features using some javascript. When we need the sheet to recalculate (eg F9 in Excel) we send the entire spreadsheet to the server, ask it to calculate everything and then refill the web page representation with the results. This may also write to the database depending on what's on the spreadsheet.
Perhaps I need your input at this point, to see if my answer is not too far off track.
So I did dig into this myself, and it did hurt a bit. Here are the particulars:
The bad:
You have to use their editor, no JSLint.
No debugger. The scripts run server side, so Firebug and other browser tools are zero help. The "View->Execution transcript" and "View->Logs" are a little help. But they don't seem to function in "onEdit" events.
The connection to the web goes through their UrlFetch Service which is doesn't have an asynchronous mode. And it doesn't function at all within "onEdit" events: http://code.google.com/p/google-apps-script-issues/issues/detail?id=185
They basically have three event types. "onLoad", "onInstall", and "onEdit". In particular I badly missed an "onClick" event.
No external library support.
The good:
It is real JavaScript, so it functions predictably, and I can use an external JSLint tool.
Shallow learning curve. Understanding sheets, ranges, and set/get values are the key concepts.
Lots of functionality for manipulating spreadsheet items, formatting, etc.
Google Data API Support? I haven't used this, but it looks like the way to go for connnecting to external web resources.
Well integrated, scripted updates on my spreadsheet are immediately visible to others viewing the spreadsheet.
Overall this environment has a ton of potential, with lots of UI capabilities, but it still seems to miss on some key functionality for doing real production development.